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
#import "MyAVController.h" | |
@implementation MyAVController | |
@synthesize captureSession = _captureSession; | |
@synthesize imageView = _imageView; | |
@synthesize customLayer = _customLayer; | |
@synthesize prevLayer = _prevLayer; |
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
//Before iOS 5 | |
for (id subview in webView.subviews) | |
if ([[subview class] isSubclassOfClass: [UIScrollView class]]) | |
((UIScrollView *)subview).bounces = NO; | |
//After iOS 5 | |
webView.scrollView.bounces = 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
-(BOOL)silenced | |
{ | |
#if TARGET_IPHONE_SIMULATOR | |
// return NO in simulator. Code causes crashes for some reason. | |
return NO; | |
#endif | |
CFStringRef state; | |
UInt32 propertySize = sizeof(CFStringRef); | |
AudioSessionInitialize(NULL, NULL, NULL, NULL); |
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
- (BOOL)isMobileNumber:(NSString *)mobileNum | |
{ | |
/** | |
* 手机号码 | |
* 移动:134[0-8],135,136,137,138,139,150,151,157,158,159,182,187,188 | |
* 联通:130,131,132,152,155,156,185,186 | |
* 电信:133,1349,153,180,189 | |
*/ | |
NSString * MOBILE = @"^1(3[0-9]|5[0-35-9]|8[025-9])\\d{8}$"; | |
/** |
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以后重载drawTextInRect | |
- (void)drawTextInRect:(CGRect)rect { | |
CGSize shadowOffset = self.shadowOffset; | |
UIColor *textColor = self.textColor; | |
CGContextRef c = UIGraphicsGetCurrentContext(); | |
CGContextSetLineWidth(c, 1); | |
CGContextSetLineJoin(c, kCGLineJoinRound); |
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
//Calculate the size necessary for the UILable | |
NSString *theText = @"Texting"; | |
CGSize theStringSize = [theText sizeWithFont:font | |
constrainedToSize:theLabel.frame.size | |
lineBreakMode:theLabel.lineBreakMode]; | |
//Adjust the size of the UILable | |
theLable.frame = CGRectMake(theLable.frame.origin.x, | |
theLable.frame.origin.y, | |
theStringSize.width, theStringSize.height); |
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
UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] init]; | |
barButtonItem.title = @"buttonName"; | |
self.navigationItem.backBarButtonItem = barButtonItem; | |
[barButtonItem release] |
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
+ (UIImage *) grayscaleImage: (UIImage *) image | |
{ | |
CGSize size = image.size; | |
CGRect rect = CGRectMake(0.0f, 0.0f, image.size.width, | |
image.size.height); | |
// Create a mono/gray color space | |
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray(); | |
CGContextRef context = CGBitmapContextCreate(nil, size.width, | |
size.height, 8, 0, colorSpace, kCGImageAlphaNone); | |
CGColorSpaceRelease(colorSpace); |
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
+ (UIImage *) imageFromURLString: (NSString *) urlstring | |
{ | |
// This call is synchronous and blocking | |
return [UIImage imageWithData:[NSData | |
dataWithContentsOfURL:[NSURL URLWithString:urlstring]]]; | |
} |
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
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 |
OlderNewer