Last active
March 7, 2017 14:34
-
-
Save michelmelo/8983499ba479a68a50e140d4b4e63176 to your computer and use it in GitHub Desktop.
Swift 3.0 - funcoes
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
| extension UIButton{ | |
| func addTextSpacing(spacing: CGFloat){ | |
| let attributedString = NSMutableAttributedString(string: (self.titleLabel?.text!)!) | |
| attributedString.addAttribute(NSKernAttributeName, value: spacing, range: NSRange(location: 0, length: (self.titleLabel?.text!.characters.count)!)) | |
| self.setAttributedTitle(attributedString, for: .normal) | |
| } | |
| } | |
| btnRegister.addTextSpacing(spacing: 4.5) | |
| extension UILabel{ | |
| func addTextSpacing(spacing: CGFloat){ | |
| let attributedString = NSMutableAttributedString(string: self.text!) | |
| attributedString.addAttribute(NSKernAttributeName, value: spacing, range: NSRange(location: 0, length: self.text!.characters.count)) | |
| self.attributedText = attributedString | |
| } | |
| } | |
| lblOne.addTextSpacing(spacing: 4.5) | |
| extension UITextField{ | |
| func addPlaceholderSpacing(spacing: CGFloat){ | |
| let attributedString = NSMutableAttributedString(string: self.placeholder!) | |
| attributedString.addAttribute(NSKernAttributeName, value: spacing, range: NSRange(location: 0, length: self.placeholder!.characters.count)) | |
| self.attributedPlaceholder = attributedString | |
| } | |
| } | |
| txtUserName.addPlaceholderSpacing(spacing: 4.5) | |
| extension UINavigationItem{ | |
| func addSpacing(spacing: CGFloat){ | |
| let attributedString = NSMutableAttributedString(string: self.title!) | |
| attributedString.addAttribute(NSKernAttributeName, value: spacing, range: NSRange(location: 0, length: self.title!.characters.count)) | |
| let label = UILabel() | |
| label.textColor = UIColor.black | |
| label.font = UIFont.systemFont(ofSize: 15, weight: UIFontWeightBold) | |
| label.attributedText = attributedString | |
| label.sizeToFit() | |
| self.titleView = label | |
| } | |
| } | |
| navigationItem.addSpacing(spacing: 2.5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment