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
[NSLayoutConstraint constraintWithItem:view | |
attribute:NSLayoutAttributeCenterX | |
relatedBy:NSLayoutRelationEqual | |
toItem:view.superview | |
attribute:NSLayoutAttributeCenterX | |
multiplier:1.f constant:0.f]; |
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 | |
foo.myBlock = ^{ | |
typeof(self) strongSelf = weakSelf; | |
}; |
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
@implementation MyViewController | |
- (UIStatusBarStyle)preferredStatusBarStyle { | |
return UIStatusBarStyleDefault; | |
} | |
- (BOOL) prefersStatusBarHidden { | |
return NO; | |
} |
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
NSNoticationCenter *center = [NSNotificationCenter defaultCenter]; | |
[center addObserver: self selector:@selector(dynamicTypeChanged:) name: UIContentSizeCategoryDidChangeNotification | |
object:nil]; | |
- (void) dynamicTypeChanged:(NSNotification *) note { | |
UIApplication *app = [UIApplication sharedApplication]; | |
NSString *category = app.preferredContentSizeCategory; | |
if ([category isEqual:UIContentSizeCategorySmall]) { |
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
float versionNumber = floor(NSFoundationVersionNumber); | |
if (versionNumber <= NSFoundationVersionNumber_iOS_6_1) { | |
// use iOS 6 style appearance | |
} else { | |
// use iOS 7 style appearance | |
} |
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
<key>UIStatusBarHidden</key><true/> | |
<key>UIViewControllerBasedStatusBarAppearance</key><false/> |
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
@interface UIImage (Tagged) | |
@property (nonatomic, copy) NSString *tag; | |
@end | |
Then we implement the setter and getter for the property using the associated object runtime methods: | |
#import <objc/runtime.h> | |
static const void *ImageTagKey = &ImageTagKey; |
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
CGImageRef image = CGImageCreateWithImageInRect([orginalImage CGImage],cropRect); | |
UIImage *cropedImage = [UIImage imageWithCGImage:image]; | |
CGImageRelease(image); |
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
- (void)viewDidLayoutSubviews | |
{ | |
[super viewDidLayoutSubviews]; | |
self.imageView.layer.masksToBounds = YES; | |
self.imageView.layer.cornerRadius = self.imageView.bounds.size.width / 2.; | |
} |
OlderNewer