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
- (NSString *)contentTypeForImageData:(NSData *)data { | |
uint8_t c; | |
[data getBytes:&c length:1]; | |
switch (c) { | |
case 0xFF: | |
return @"image/jpeg"; | |
case 0x89: | |
return @"image/png"; | |
case 0x47: |
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
systemLayoutSizeFittingSize: | |
boundingRectWithSize:options:attributes:context: |
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 *)imageFromView:(UIView *)view { | |
UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, 0.0); | |
[view drawViewHierarchyInRect:view.bounds afterScreenUpdates:NO]; | |
UIImage * img = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
return img; | |
} |
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 *)imageRotatedByDegrees:(UIImage*)oldImage deg:(CGFloat)degrees{ | |
//Calculate the size of the rotated view's containing box for our drawing space | |
UIView *rotatedViewBox = [[UIView alloc] initWithFrame:CGRectMake(0,0,oldImage.size.width, oldImage.size.height)]; | |
CGAffineTransform t = CGAffineTransformMakeRotation(degrees * M_PI / 180); | |
rotatedViewBox.transform = t; | |
CGSize rotatedSize = rotatedViewBox.frame.size; | |
//Create the bitmap context | |
UIGraphicsBeginImageContext(rotatedSize); | |
CGContextRef bitmap = UIGraphicsGetCurrentContext(); |
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)startPlaybackForItemWithURL:(NSURL*)url { | |
// First create an AVPlayerItem | |
AVPlayerItem* playerItem = [AVPlayerItem playerItemWithURL:url]; | |
// Subscribe to the AVPlayerItem's DidPlayToEndTime notification. | |
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(itemDidFinishPlaying:) name:AVPlayerItemDidPlayToEndTimeNotification object:playerItem]; | |
// Pass the AVPlayerItem to a new player | |
AVPlayer* player = [[[AVPlayer alloc] initWithPlayerItem:playerItem] autorelease]; |
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
/* | |
iOS7中UIViewController新增的属性extendedLayoutIncludesOpaqueBars和edgesForExtendedLayout可以解决该问题。 | |
其中这个属性指定了当Bar使用了不透明图片时,视图是否延伸至Bar所在区域,默认值时NO。 | |
而edgesForExtendedLayout则是表示视图是否覆盖到四周的区域,默认是UIRectEdgeAll,即上下左右四个方向都会覆盖, | |
那么为让顶部不进行延伸到导航栏覆盖的区域,我们可以把顶部区域延伸去掉。 | |
*/ | |
self.extendedLayoutIncludesOpaqueBars = 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
#!/bin/sh | |
if ! ([ -f "$1" ]); then | |
echo \"${1}\"文件不存在 | |
exit | |
fi | |
ipaName=${1%.ipa} | |
if [ "$ipaName" = "$1" ]; then | |
echo \"${1}\"不是ipa文件 | |
exit |
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*) imageWithUIView:(UIView*) view{ | |
// 创建一个bitmap的context | |
// 并把它设置成为当前正在使用的context | |
UIGraphicsBeginImageContext(view.bounds.size); | |
CGContextRef currnetContext = UIGraphicsGetCurrentContext(); | |
//[view.layer drawInContext:currnetContext]; | |
[view.layer renderInContext:currnetContext]; | |
// 从当前context中创建一个改变大小后的图片 | |
UIImage* image = UIGraphicsGetImageFromCurrentImageContext(); | |
// 使当前的context出堆栈 |
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
UIView *view = [UIView alloc]init]; | |
view.userInteractionEnabled = NO; |