tag uiimaageview

来源:互联网 发布:c 编写windows程序 编辑:程序博客网 时间:2024/05/16 10:18

http://www.cnblogs.com/wendingding/p/3751316.html

http://blog.sina.com.cn/s/blog_7b9d64af0101akhn.html

UIImageView是使用频率最高的控件之一了。那就开始总结一下了。


1.初始化UIImageView

UIImageView *imgShadow = [[UIImageView allocinitWithFrame:CGRectMake(50150,15080)];

    [imgShadow setImage:[UIImage imageNamed:@"9.jpg"]];


2.为UIImageView添加特效

// 是否栅格化。

    // YES:会栅格化层中的数据(如:图像)

    // NO:不栅格化

    // 我们知道,栅格化数据是将矢量图变为位图。所以,如果层中的内容是变动的,每次都需要栅格化,就会影像效率。一般设置为NO

    [imgShadow.layer setShouldRasterize:NO];

    

    // 设置边框颜色

    [imgShadow.layer setBorderColor: [[UIColor whiteColor] CGColor]];

    // 设置边框宽度

    [imgShadow.layer setBorderWidth1.0];

    // 设置投影偏移量,CGSizeMake(x轴方向, y轴方向)

    [[imgShadow layer] setShadowOffset:CGSizeMake(1, 1)];

    // 设置投影颜色

    [[imgShadow layer] setShadowColor:[UIColor redColor].CGColor];

    // 设置投影半径

    [[imgShadow layersetShadowRadius:3];

    // 设置透明度

    [[imgShadow layer] setShadowOpacity:1];


 

 // 当设置为YES时,超过边界的将被遮盖(隐藏),经常与cornerRadius,属性使用。这样,圆角外的区域将被遮盖

 

[imgShadow.layer setMasksToBounds:YES];

    // 设置圆角

    imgShadow.layer.cornerRadius = 10;


这样,一个图片效果出来了。


0 0
原创粉丝点击