我想为我的图像创建一个文本叠加层.问题是,如果生病了尝试添加第二个文本,如字幕,它会忽略我的字体大小.
原文链接:https://www.f2er.com/swift/319276.htmltitleLayer.frame = CGRectMake(0,80,imageView.bounds.width,50) subTitleLayer.frame = CGRectMake(0,130,40) titleLayer.string = "Title" subTitleLayer.string = "Subtitle" let fontName: CFStringRef = "HelveticaNeue" let fontSubName: CFStringRef = "HelveticaNeue-Thin" titleLayer.font = CTFontCreateWithName(fontName,16,nil) subTitleLayer.font = CTFontCreateWithName(fontSubName,10,nil) // Ignores the font-size imageView.layer.addSublayer(titleLayer) imageView.layer.addSublayer(subTitleLayer)
新字体是正确的,但它总是与titleFont一样大小(16).如何更改字体大小?