Reputation: 178
I am using the awesome framework MGSwipeTableCell. It works very well but I would like to know how to set a custom UIFont for the title of the buttons.
I tried to do it in the framework files themselves but they are written in Objective-C and I only know Swift.
Here's my code :
cell.leftButtons = [MGSwipeButton(title: "Hello", backgroundColor: UIColor.greenColor(), callback: {
(sender: MGSwipeTableCell!) -> Bool in
return true
}),
Upvotes: 2
Views: 534
Reputation: 2906
Since MGSwipeButton
is a subclass of UIButton, you can can change the font like this:
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]
Upvotes: 1
Reputation: 7013
According to doc. you can use it in that form
cell.leftButtons = MGSwipeButton(title: "Hello", backgroundColor: UIColor.greenColor(), callback: {
(sender: MGSwipeTableCell!) -> Bool in
print("Convenience callback for swipe buttons!")
return true
})
Since MGSwipeTableCell
extends from UIButton, you can change the font like :
cell.leftButtons!.font = UIFont(name: "YourfontName", size: 20)
Upvotes: 0