iOS 给一个uiview设置shadow
2012-03-30 17:47
411 查看
给view设置shadow 主要是操作的caller上的,所以我们要先导入头文件
#import
<QuartzCore/QuartzCore.h>
然后,在函数
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
CALayer *layer =
self.layer;
[layer setBorderColor:[[UIColor
yellowColor] CGColor]];//边框的颜色
layer.shadowOffset =
CGSizeMake(0,
3);
layer.shadowRadius =
5.0;
layer.shadowColor = [UIColor
yellowColor].CGColor;//shadow的颜色
layer.shadowOpacity =
0.8;
[layer setBorderWidth:2.75];
}
touch结束后,设置回来
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
CALayer *layer =
self.layer;
//这里的rgba可以自己设置
[layer
setBorderColor:[[UIColor
colorWithRed:0.588
green:0.737
blue:0.976
alpha:1.0]
CGColor]];
layer.shadowOffset =
CGSizeMake(0,
8);
layer.shadowRadius =
5.0;
layer.shadowColor = [UIColor
blackColor].CGColor;
layer.shadowOpacity =
0.8;
[layer
setBorderWidth:2.75];
}
#import
<QuartzCore/QuartzCore.h>
然后,在函数
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
CALayer *layer =
self.layer;
[layer setBorderColor:[[UIColor
yellowColor] CGColor]];//边框的颜色
layer.shadowOffset =
CGSizeMake(0,
3);
layer.shadowRadius =
5.0;
layer.shadowColor = [UIColor
yellowColor].CGColor;//shadow的颜色
layer.shadowOpacity =
0.8;
[layer setBorderWidth:2.75];
}
touch结束后,设置回来
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
CALayer *layer =
self.layer;
//这里的rgba可以自己设置
[layer
setBorderColor:[[UIColor
colorWithRed:0.588
green:0.737
blue:0.976
alpha:1.0]
CGColor]];
layer.shadowOffset =
CGSizeMake(0,
8);
layer.shadowRadius =
5.0;
layer.shadowColor = [UIColor
blackColor].CGColor;
layer.shadowOpacity =
0.8;
[layer
setBorderWidth:2.75];
}
相关文章推荐
- IOS 设置一个UIView里面的全部控件状态
- 设置视图IOS开发(97)之自定义视图之使用XIB自定义一个UIView
- IOS--UIViewUIButtonUIImageView设置圆角、阴影、边框的方法
- iOS开发中设置header 的一个解决。
- iOS设置圆形(圆角)UIView、UIButton的简单方法
- iOS设置同一个Label的不同颜色的字体
- ios UIview 设置透明度遇到的问题
- ios UIView控件设置动画后添加点击事件不起作用
- ios中如何将UIView设置为圆角
- ios 给一个控制器的view设置背景图片
- iOS-UIView-设置背景图片4种方式
- ios UIView设置背景图片的方法
- IOS 如何从ViewController获取一个UIView上的某种或者某个控件
- ios UIView 和 UIButton边框和阴影设置
- 设置UIView阴影shadow 边框 边框颜色
- iOS下uiview和uiscrollview设置背景图片的源码
- IOS开发(97)之自定义视图之使用XIB自定义一个UIView
- iOS开发,如何让xib关联一个UIView?
- iPhone之为UIView设置阴影(CALayer的shadowColor,shadowOffset,shadowOpacity,shadowRadius,shadowPath属性)
- ios 设置一个textField不可编辑