swift - 使用 MGSwipeTableCell 时自定义字体?

标签 swift frameworks uibutton

我正在使用很棒的框架 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/

相关文章:

ruby-on-rails - Ruby on Rails 的所有 "conventions"是什么?

iphone - UIButton 不允许 UIScrollView 滚动

ios - 以编程方式在 iOS 上创建了一个按钮,但按下时没有任何 Action

swift - 如何在 Swift 中流式传输 mp3 url (iOS)?

ios - Xcode 拒绝让我将 Swift 文件导入 Objective-C 文件 ('projectname-swift.h' 未找到)

php - 在 Laravel View 中使用 CSS?

php - 如何直接从查询字符串(URL)获取 Yii 参数

swift - 当应用程序进入后台时按钮跳转位置

swift - 如何转换 [String : Any] to [NSAttributedStringKey : Any]

ios - 数据未保存在 sqlite 核心数据库中