生成不规则的形状
来源:互联网 发布:简书 知乎 豆瓣哪个好 编辑:程序博客网 时间:2024/06/09 23:01
生成一个不规则图形的方式,比如下面的效果:
需要将文字部分用多边形圈起来。这里做了一个多边形的图,然后填充为黑色,设置了alpha透明度,就产生了这样的效果。
代码如下:
- (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开发生成不规则的形状
- 不规则形状的剪切
- 如何生成不规则形状的mask,以解决对图像不规则区域设置ROI的问题
- 如何生成不规则形状的mask,以解决对图像不规则区域设置ROI的问题 .
- 如何生成不规则形状的mask,以解决对图像不规则区域设置ROI的问题
- 如何生成不规则形状的mask,以解决对图像不规则区域设置ROI的问题
- 创建不规则形状的Control
- 不规则窗体形状的ToolTip
- 不规则窗体形状的ToolTip .
- 不规则形状的碰撞检测
- 如何生成不规则形状的mask,以解决对图像不规则区域设置ROI的问题(ZZ)
- 转如何生成不规则形状的mask,以解决对图像不规则区域设置ROI的问题
- VC---创建一个不规则形状的窗口
- 如何创建一个不规则形状的窗口
- box2d中创建不规则的形状
- 创建“不规则形状”的Air透明窗体
- 获取图片中不规则形状的一部分
- 收藏几个可用的RTSP
- 驳:SpringMVC中@ResponseBody的问题
- c#常用类库----计算机信息类
- 保存数据-1应用程序得沙盒
- 从零开始到现在
- 生成不规则的形状
- JDWP Transport dt_socket failed to initialize
- ****Android如何引用其他工程
- Oracle中的CHR()函数
- 关于面向对象思想分析与设计
- 算法导论8-3变长数据项排序-整数数组-字符串
- IOS开发之──ASIHTTPRequest详解
- Doxygen初学与简单应用
- _init _fini constructor destructor