Skip to content

Instantly share code, notes, and snippets.

View Tricertops's full-sized avatar
:octocat:

Martin Kiss Tricertops

:octocat:
View GitHub Profile
@Tricertops
Tricertops / gist:5142819
Last active December 14, 2015 20:19
Adjusting frame of UIView. The easier way.
// UIView category
- (void)adjustFrame:(void(^)(CGRect *frame))block {
CGRect frame = self.frame;
block(&frame);
self.frame = frame;
}
@Tricertops
Tricertops / UIColor+Random.m
Created March 4, 2013 13:10
Great debugging tool when you have a lot of views ;)
@implementation UIColor (Random)
+ (instancetype)randomColor {
return [self colorWithRed:(arc4random() % 255) / 255.f
green:(arc4random() % 255) / 255.f
blue:(arc4random() % 255) / 255.f
alpha:1];
}
@Tricertops
Tricertops / Validate NSString as number
Created February 2, 2013 08:52
Three options how to validate `NSString` instance to contain numeric value.
NSString *theString; // You have a string.
/// Option 1: floatValue
if ([theString floatValue] != 0 || [theString hasPrefix:@"0.0"] || [theString isEqualToString:@"0"]) {
// theString should be number
}