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
| // UIView category | |
| - (void)adjustFrame:(void(^)(CGRect *frame))block { | |
| CGRect frame = self.frame; | |
| block(&frame); | |
| self.frame = frame; | |
| } |
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
| @implementation UIColor (Random) | |
| + (instancetype)randomColor { | |
| return [self colorWithRed:(arc4random() % 255) / 255.f | |
| green:(arc4random() % 255) / 255.f | |
| blue:(arc4random() % 255) / 255.f | |
| alpha:1]; | |
| } |
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
| NSString *theString; // You have a string. | |
| /// Option 1: floatValue | |
| if ([theString floatValue] != 0 || [theString hasPrefix:@"0.0"] || [theString isEqualToString:@"0"]) { | |
| // theString should be number | |
| } | |
NewerOlder