Guest User

Untitled

a guest
Dec 13th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. + (void)setFontName:(NSString*)fontName onObject:(id)object {
  2. if ([object respondsToSelector:@selector(setFont:)]) {
  3. UIFont* font = [UIFont fontWithName:fontName size:((UIFont *)[object font]).pointSize];
  4. [object setFont:font];
  5. }
  6. }
  7.  
  8. public static func setFontRewriting(fontName: String, object: AnyObject) {
  9. if object.responds(to:#selector(setter: object.font)) {
  10. let currentFont: UIFont = object.font
  11. let fontToSet = UIFont(name: fontName, size: currentFont.pointSize)
  12. object.font = UIFont(name: fontName, size: currentFont.pointSize) //doesn't work, getting various syntax errors
  13. }
  14. }
Add Comment
Please, Sign In to add comment