Created
May 31, 2016 08:39
-
-
Save InstaRobot/898b96041b42583b4922dc7f1f40dbf1 to your computer and use it in GitHub Desktop.
Можно быстро заменить текст картинкой
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class TableViewRowAction: UITableViewRowAction { | |
| var image: UIImage? | |
| func _setButton(button: UIButton) { | |
| if let image = image, let titleLabel = button.titleLabel { | |
| let labelString = NSString(string: titleLabel.text!) | |
| let titleSize = labelString.sizeWithAttributes([NSFontAttributeName: titleLabel.font]) | |
| button.tintColor = UIColor.whiteColor() | |
| button.setImage(image.imageWithRenderingMode(.AlwaysTemplate), forState: .Normal) | |
| button.imageEdgeInsets.right = -titleSize.width | |
| } | |
| } | |
| } // class TableViewRowAction | |
| override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? { | |
| let delete = TableViewRowAction(style: UITableViewRowActionStyle.Default, title: " ") { action, indexPath in } | |
| delete.image = UIImage(named: "trashImg") | |
| let sharing = TableViewRowAction(style: UITableViewRowActionStyle.Default, title: " ") { action, indexPath in } | |
| sharing.backgroundColor = UIColor.lightGrayColor() | |
| sharing.image = UIImage(named: "sharingImg") | |
| return [delete, sharing] | |
| } // editActionsForRowAtIndexPath | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment