ios _UIImageView
来源:互联网 发布:盐城英语口语网络大赛 编辑:程序博客网 时间:2024/06/07 05:15
// (1)创建
UIImageView *imageView = [[UIImageView alloc ] init];
UIImage *image = [UIImage imageNamed:@"image_photo"];imageView.image = image;// (2)设置圆角imageView.layer.masksToBounds = YES;imageView.layer.cornerRadius = 10;// (3)设置边框颜色和大小imageView.layer.borderColor = [UIColor orangeColor].CGColor;imageView.layer.borderWidth = 2;// (4)contentMode属性:当图片小于imageView的大小处理图片显示// 这个属性是用来设置图片的显示方式,如居中、居右,是否缩放等,有以下几个常量可供设定://// UIViewContentModeScaleToFill :填充整个UIViewContentModeScaleAspectFit UIViewContentModeScaleAspectFill UIViewContentModeRedraw UIViewContentModeCenter UIViewContentModeTop UIViewContentModeBottom UIViewContentModeLeft UIViewContentModeRight UIViewContentModeTopLeft UIViewContentModeTopRight UIViewContentModeBottomLeft UIViewContentModeBottomRightimageView.contentMode = UIViewContentModeScaleAspectFit;//(5)播放一系列图片UIImage *image1 = [UIImage imageNamed:@"homeNaviLeftBtn"];UIImage *image2 = [UIImage imageNamed:@"homeNaviRightBtn"];UIImage *image3 = [UIImage imageNamed:@"image_photo"];NSArray *imagesArray = @[image1,image2,image3];imageView.animationImages = imagesArray;// 设定所有的图片在多少秒内播放完毕imageView.animationDuration = [imagesArray count];// 不重复播放多少遍,0表示无数遍imageView.animationRepeatCount = 0;// 开始播放[imageView startAnimating]; //(6)为图片添加单击事件:一定要先将userInteractionEnabled置为YES,这样才能响应单击事件imageView.userInteractionEnabled = YES;UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView:)];[imageView addGestureRecognizer:singleTap];//(7)其他设置
// imageView.hidden = YES或者NO; // 隐藏或者显示图片
imageView.alpha =0.5; // 设置透明度
// 设置高亮时显示的图片
//imageView.highlightedImage = (UIImage *)hightlightedImage;
//imageView.image = (UIImage *)image; // 设置正常显示的图片//设置位置 1)修改center ImageView的中间点2)修改frameimageView.frame = CGRectMake(10, 66, 300, 400);
// imageView.center = CGPointMake(0, 0);
0 0
- ios _UIImageView
- UI基础_UIImageView的contentMode总结
- iOS
- iOS
- IOS
- iOS
- iOS
- IOS
- ios
- iOS
- iOS
- IOS
- iOS
- ios
- ios ~~~~~
- ios
- IOS
- IOS
- HBase内置过滤器的一些总结
- 黑马程序员日记-4
- Cisco单臂路由配置,图文实例详解
- Windows下C语言操作硬件设备的方法
- 第11周项目1-验证算法(4)哈夫曼编码的算法验证
- ios _UIImageView
- 邻接矩阵-C++
- CANopen对象字典
- ADB SERVER的端口被占用
- linux使用shell批量解压rar文件
- 三层交换机实现VLAN间通信
- mysql 增量备份还原
- 黑马程序员日记-5
- C++学习记录之函数返回值为指针的问题