Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save InstaRobot/898b96041b42583b4922dc7f1f40dbf1 to your computer and use it in GitHub Desktop.

Select an option

Save InstaRobot/898b96041b42583b4922dc7f1f40dbf1 to your computer and use it in GitHub Desktop.
Можно быстро заменить текст картинкой
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