我正在使用很棒的框架 MGSwipeTableCell。它工作得很好,但我想知道如何为按钮的标题设置自定义 UIFont。
我尝试在框架文件中这样做,但它们是用 Objective-C 编写的,而且我只懂 Swift。
这是我的代码:
cell.leftButtons = [MGSwipeButton(title: "Hello", backgroundColor: UIColor.greenColor(), callback: {
(sender: MGSwipeTableCell!) -> Bool in
return true
}),
最佳答案
由于 MGSwipeButton
是 UIButton 的子类,您可以像这样更改字体:
let swipeButton = MGSwipeButton(title: "Hello", backgroundColor: UIColor.greenColor(), callback: {
(sender: MGSwipeTableCell!) -> Bool in
return true
})
swipeButton.titleLabel?.font = UIFont(name: "fontName", size: 14)
cell.leftButtons = [swipeButton]
关于swift - 使用 MGSwipeTableCell 时自定义字体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36743978/