Skip to content

Instantly share code, notes, and snippets.

View spiridonkopicl's full-sized avatar

Predrag Karic spiridonkopicl

View GitHub Profile
@spiridonkopicl
spiridonkopicl / buttonExtension.swift
Last active March 7, 2019 07:14
UIButton extension - set title to the left and image to the right
extension UIButton {
func addRightImage(image: UIImage, offset: CGFloat) {
self.setImage(image, for: .normal)
self.translatesAutoresizingMaskIntoConstraints = false
self.imageView?.translatesAutoresizingMaskIntoConstraints = false
self.titleLabel?.translatesAutoresizingMaskIntoConstraints = false
self.imageView?.contentMode = .right
self.titleLabel?.adjustsFontSizeToFitWidth = false
self.titleLabel?.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: offset).isActive = true
self.imageView?.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: -offset).isActive = true
@spiridonkopicl
spiridonkopicl / separator.swift
Created March 7, 2019 07:12
UITableViewCell separators go edge to edge
tableView.layoutMargins = UIEdgeInsets.zero
tableView.separatorInset = UIEdgeInsets.zero
//then
cell.layoutMargins = UIEdgeInsets.zero