Last active
August 29, 2015 13:57
-
-
Save Altimor/9919725 to your computer and use it in GitHub Desktop.
This file contains 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
// | |
// UILabel+AprilFools.m | |
// | |
// Created by Florent Crivello on 4/1/14. | |
// | |
#import "UILabel+AprilFools.h" | |
#import "objc/runtime.h" | |
#import "objc/message.h" | |
@implementation UILabel (AprilFools) | |
+ (void)load { | |
Method originalMethod = class_getInstanceMethod([UILabel class], @selector(willMoveToSuperview:)); | |
Method newMethod = class_getInstanceMethod([UILabel class], @selector(swizzle_willMoveToSuperview:)); | |
if (class_addMethod([UILabel class], @selector(willMoveToSuperview:), method_getImplementation(newMethod), method_getTypeEncoding(newMethod))) { | |
class_replaceMethod([UILabel class], @selector(swizzle_willMoveToSuperview:), method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod)); | |
} else { | |
method_exchangeImplementations(originalMethod, newMethod); | |
} | |
} | |
- (void)swizzle_willMoveToSuperview:(UIView *)newSuperview { | |
self.font = [UIFont fontWithName:@"ChalkboardSE-Regular" size:self.font.pointSize+1]; | |
self.text = [self.text lowercaseString]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
And the .h is just: