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
#define BIT_ONE 1 | |
#define BIT_TWO 2 | |
#define BIT_THREE 4 | |
#define BIT_FOUR 8 | |
int flag = 0; | |
// Set bits | |
flag |= BIT_ONE | BIT_THREE; | |
NSLog(@"Bits: %@", [self intToBinaryString:flag]); |
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
CAShapeLayer* mask = [[CAShapeLayer alloc] init]; | |
mask.frame = CGRectMake(0, 0, segmentedControl.bounds.size.width-1, segmentedControl.bounds.size.height); | |
mask.path = [[UIBezierPath bezierPathWithRoundedRect:mask.frame cornerRadius:4] CGPath]; | |
segmentedControl.layer.mask = mask; |
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
#ifdef TARGET_IPHONE_SIMULATOR | |
// Code to only run in the simulator | |
#endif |
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
+ (CGSize)labelSizeForString:(NSString *)string fontSize:(CGFloat)fontSize | |
{ | |
return [string boundingRectWithSize:CGSizeMake(DETAIL_TEXT_LABEL_WIDTH, 2000.0) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:fontSize]} context:nil].size; | |
} |
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
__weak typeof(self) weakSelf = self; | |
[self doABlockOperation:^{ | |
__strong typeof(weakSelf) strongSelf = weakSelf; | |
if (strongSelf) { | |
... | |
} | |
}]; |
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
po [[UIWindow keyWindow] _autolayoutTrace] |
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
[[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) to:nil from:self forEvent:nil] |
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
// The first two lines can be set in Interface builder | |
self.titleLabel.numberOfLines = 0; | |
self.titleLabel.lineBreakMode:NSLineBreakByWordWrapping; | |
[self.titleLabel setPreferredMaxLayoutWidth:self.frame.size.width-50]; | |
// Also in IB, set a constraint on the label so the height it >= the height of a single line |