iOS开发点滴-添加阴影效果
2016-04-26 19:47
543 查看
UIBezierPath *shadowPath = [UIBezierPath bezierPathWithRect:imageView.bounds];
imageView.layer.masksToBounds = NO;
imageView.layer.shadowColor = [UIColor blackColor].CGColor;
imageView.layer.shadowOffset = CGSizeMake(0.0f, 5.0f);
imageView.layer.shadowOpacity = 0.5f;
imageView.layer.shadowPath = shadowPath.CGPath;
//添加显示
UIImage *image = [UIImage
imageNamed:@"touxiang"];
UIImageView *imageView = [[UIImageView
alloc]initWithImage:image];
imageView.frame =
CGRectMake(50,
100, 200,
200);
//添加边框
// CALayer * layer = [imageView layer];
// layer.borderColor = [[UIColor redColor] CGColor];
// layer.borderWidth = 5.0f;
// imageView.layer.borderColor = [UIColor lightGrayColor].CGColor;
// imageView.layer.borderWidth = 5.0f;
//添加四个边阴影
// imageView.layer.shadowColor = [UIColor greenColor].CGColor;//阴影颜色
// imageView.layer.shadowOffset = CGSizeMake(0, 0);//偏移距离
// imageView.layer.shadowOpacity = 0.5;//不透明度
// imageView.layer.shadowRadius = 10.0;//半径
//添加两个边阴影
imageView.layer.shadowColor = [UIColor
blueColor].CGColor;//阴影颜色
imageView.layer.shadowOffset =
CGSizeMake(4,
4);//偏移距离
imageView.layer.shadowOpacity =
0.5;//不透明度
imageView.layer.shadowRadius =
2.0;//半径
[self.view
addSubview:imageView];
imageView.layer.masksToBounds = NO;
imageView.layer.shadowColor = [UIColor blackColor].CGColor;
imageView.layer.shadowOffset = CGSizeMake(0.0f, 5.0f);
imageView.layer.shadowOpacity = 0.5f;
imageView.layer.shadowPath = shadowPath.CGPath;
//添加显示
UIImage *image = [UIImage
imageNamed:@"touxiang"];
UIImageView *imageView = [[UIImageView
alloc]initWithImage:image];
imageView.frame =
CGRectMake(50,
100, 200,
200);
//添加边框
// CALayer * layer = [imageView layer];
// layer.borderColor = [[UIColor redColor] CGColor];
// layer.borderWidth = 5.0f;
// imageView.layer.borderColor = [UIColor lightGrayColor].CGColor;
// imageView.layer.borderWidth = 5.0f;
//添加四个边阴影
// imageView.layer.shadowColor = [UIColor greenColor].CGColor;//阴影颜色
// imageView.layer.shadowOffset = CGSizeMake(0, 0);//偏移距离
// imageView.layer.shadowOpacity = 0.5;//不透明度
// imageView.layer.shadowRadius = 10.0;//半径
//添加两个边阴影
imageView.layer.shadowColor = [UIColor
blueColor].CGColor;//阴影颜色
imageView.layer.shadowOffset =
CGSizeMake(4,
4);//偏移距离
imageView.layer.shadowOpacity =
0.5;//不透明度
imageView.layer.shadowRadius =
2.0;//半径
[self.view
addSubview:imageView];
相关文章推荐
- iOS LLDB调试精解
- iOS8新特性之交互式通知
- iOS dSYM文件结构剖析(上)
- iOS Crash文件的解析(一)
- iOS单元测试GHUnit + OCMock(使用cocoapods版)
- iOS基础:获取资源文件的方法
- iOS开发-你真的会用SDWebImage?(转发)
- IOS+openCV在Xcode的入门开发
- iOS实现左右循环滑动ScrollVIew
- IOS实现自动循环滚动广告--ScrollView的优化和封装
- iOS dataFormatter 8小时 误差
- ios runtime void method_exchangeImplementations
- iOS运行时与method swizzling
- iOS运行时与method swizzling
- [ios]CGContext 函数说明
- [ios]presentModalViewController和dismissModalViewControllerAnimated汇总
- iOS-正则表达式的使用
- iOS--串口通讯初始化
- 【转载】Xcode 4.1~4.6 + iOS 5、iOS 6免证书(iDP)开发+真机调试+生成IPA全攻略
- 如何让iOS应用程序访问到 dev下的设备