如何在swift中更改NSAttributedString的字体大小和字体颜色?
@IBOutlet weak var detailsTextView: UITextView!
if let data = htmltext.data(using: String.Encoding.utf8, allowLossyConversion: true)
{
do
{
let newFont = UIFont(name: "Georgia", size: 22.0) ?? UIFont()
我尝试更改占位符文本颜色。下面的代码不起作用:
let color = NSColor.redColor()
let attrs = [NSForegroundColorAttributeName: color]
let placeHolderStr = NSAttributedString(string: "My placeholder", attributes: attrs)
myTextField.placeholderAttributedString = placeHolderStr
我得到了错误-[NSTextField setPlaceholderAttribute
在更新到iOS 15之后,我以这种方式实现了UITabBar配置: let backgroundColor = UIColor.grey
let selectedItemTextColor = UIColor.blue
let unselectedItemTextColor = UIColor.black
if #available(iOS 15, *) {
let tabBarAppearance = UITabBarAppearance()
tabBarAppearance.backgroundColor = ba