Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. import UIKit
  2.  
  3. @IBDesignable
  4. class TemplateImageButton: UIButton {
  5.  
  6. #if TARGET_INTERFACE_BUILDER
  7. let templateImageView = UIImageView()
  8.  
  9. override init(frame: CGRect) {
  10. super.init(frame: frame)
  11. addSubview(templateImageView)
  12. }
  13.  
  14. required init?(coder aDecoder: NSCoder) {
  15. super.init(coder: aDecoder)
  16. addSubview(templateImageView)
  17. }
  18.  
  19. override func layoutSubviews() {
  20. templateImageView.frame = bounds
  21. templateImageView.image = currentImage?.withRenderingMode(.alwaysTemplate)
  22. }
  23. #endif
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement