Archive for the ‘cocoa’ tag
iphone程序中跳转到appstore评论界面
在程序中加入appstore的review跳转,实现方法很简单,就是让系统去打开一个review的链接,代码如下:
- (void) gotoWriteReviews { NSString* appID = NSLocalizedString(@"itunesconnect_appid", nil); //这里是itunes connect生成的一串数字id NSString *u = [NSString stringWithFormat:@"http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=%@&onlyLatestVersion=true&pageNumber=0&sortOrdering=1&type=Purple+Software",appID]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:u]]; }
在图片上盖一层mask
- (UIImage*) createImage:(UIImage*)_image withMask:(UIImage*)_mask { CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef context = CGBitmapContextCreate(NULL, _image.size.width, _image.size.height, 8, 0, colorSpace, kCGImageAlphaPremultipliedLast); CGColorSpaceRelease(colorSpace); CGRect rect = CGRectMake(0, 0, _image.size.width, _image.size.height); UIColor *bColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:1]; CGContextSetFillColorWithColor(context, [bColor CGColor]); //黑色是不透明,白色是透明 CGContextFillRect(context, rect); CGContextClipToMask(context, rect, [_mask CGImage]); CGContextDrawImage(context, rect, [_image CGImage]); CGImageRef newImage = CGBitmapContextCreateImage(context); CGContextRelease(context); UIImage* _newImage = [[UIImage alloc] initWithCGImage:newImage]; CGImageRelease(newImage); return [_newImage autorelease]; }
最先创建了一个灰度的颜色空间导致合成出来的mask颜色都是反的,黑色的显出白色,后来发现一篇例子是用RGB颜色空间来做再自己加上黑色填充后就得到了想要的效果,效果图:
