生成一个不规则图形的方式,比如下面的效果:
需要将文字部分用多边形圈起来。这里做了一个多边形的图,然后填充为黑色,设置了alpha透明度,就产生了这样的效果。
代码如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
- (void)loadView {
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation: UIStatusBarAnimationSlide];
UIImage *image=[UIImage imageNamed:@"1.jpg"];
UIImageView *backView=[[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
backView.image=image;
backView.alpha=0.6;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(nil,768,1024,8,0,
colorSpace,kCGImageAlphaPremultipliedLast);
CFRelease(colorSpace);
UIImageView *contentView = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
CGColorRef fillColor = [[UIColor blackColor] CGColor];
CGContextSetFillColor(context, CGColorGetComponents(fillColor));
CGContextBeginPath(context);
CGContextMoveToPoint(context, 160.0f, 230.0f);
CGContextAddLineToPoint(context, 600.0f, 230.0f);
CGContextAddLineToPoint(context, 600.0f, 100.0f);
CGContextAddLineToPoint(context, 370.0f, 50.0f);
CGContextAddLineToPoint(context, 200.0f, 100.0f);
CGContextClosePath(context);
CGContextFillPath(context);
contentView.image=[[UIImage alloc] initWithCGImage:CGBitmapContextCreateImage(context)];
contentView.alpha=0.3;
CGContextRelease(context);
self.view=[[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
[self.view addSubview:backView];
[self.view addSubview:contentView];
[backView release];
[contentView release];
[image release];
}
|
分享到:
相关推荐
iPhone头像生成器
iPhone开发实战 iPhone开发 iPhone iPhone4 iPhone开发实战 iPhone开发 iPhone iPhone4
Iphone开发系列源码——Iphone主题源码Iphone开发系列源码——Iphone主题源码Iphone开发系列源码——Iphone主题源码Iphone开发系列源码——Iphone主题源码Iphone开发系列源码——Iphone主题源码Iphone开发系列源码...
这里推荐两本书《objective-c基础教程》和《iphone开发基础教程》,这两本都是圣经级的巨作,我相信每一个iphone开发人员应该都不会错过这两本书的。 等你xcode和objective-c摸熟之后,或者说,上面提到的那两...
Iphone开发系列源码——iPhone版Wordpress源代码Iphone开发系列源码——iPhone版Wordpress源代码Iphone开发系列源码——iPhone版Wordpress源代码Iphone开发系列源码——iPhone版Wordpress源代码Iphone开发系列源码...
Iphone开发系列源码——Image图片缩放随着手指Iphone开发系列源码——Image图片缩放随着手指Iphone开发系列源码——Image图片缩放随着手指Iphone开发系列源码——Image图片缩放随着手指Iphone开发系列源码——Image...
让不懂编程的人爱上iPhone开发002.pdf
iPhone开发,iPhone开发教程,iPhone开发基础教程PDF版
《iPhone开发基础教程》内容完整丰富,具有较强的通用性,编程领域中各层次读者都能通过《iPhone开发基础教程》快速学习iPhone开发,提高相关技能。iPhone 是一种全新的移动平台,苹果公司为它推出了强大的软件开发...
资源名称:iPhone开发入门到精通视频教程资源目录:【】iOS开发源码系列---工具【】iOS开发源码系列---应用【】iOS开发源码系列---游戏【】iOS开发源码系列---类库与框架【】iOS开发真机测试与发布【】iOS开发视频...
本书全面探讨了iPhone平台的两种编程方式——Web开发和SDK编程。全在Web开发方面,分别介绍了三个iPhone Web库,即WebKit、iUI和Canvas,并讨论了Web开发环境Dashcode,最后阐述Web应用程序的调试。在SDK开发方面,...
轻松学iPhone共分3篇。第1篇介绍iPhone的发展、iPhone开发环境以及开发工具的安装过程、iPhone Simulator模拟器
iPhone游戏开发iPhone游戏开发iPhone游戏开发iPhone游戏开发iPhone游戏开发iPhone游戏开发iPhone游戏开发iPhone游戏开发iPhone游戏开发iPhone游戏开发
知名的Head First系列丛书之一,风格与其他Head First系列一脉相承,一定能让读者轻松学会iPhone开发,《深入浅出iPhone开发》是针对iPhone开发的初学者设计的,以几个应用实例的开发为例,循序渐进地对iPhone开发的...
iphone开发秘籍,移动手机开发,参照软件开发应用
Iphone开发系列源码——多功能播放器源码Iphone开发系列源码——多功能播放器源码Iphone开发系列源码——多功能播放器源码Iphone开发系列源码——多功能播放器源码Iphone开发系列源码——多功能播放器源码Iphone开发...
这是一本很不错的iphone开发入门级教程
iPhone开发实战
《深入浅出iPhone开发》,本书是针对iPhone开发的初学者设计的,以几个应用实例的开发为例,循序渐进地对iPhone开发的各个方面进行了讲解。
Iphone开发系列源码——星级评价实现代码Iphone开发系列源码——星级评价实现代码Iphone开发系列源码——星级评价实现代码Iphone开发系列源码——星级评价实现代码Iphone开发系列源码——星级评价实现代码Iphone开发...