UIImageView圆角,自适应图片宽高比例,图片拉伸,缩放比例
来源:互联网 发布:细骨料试验记录数据 编辑:程序博客网 时间:2024/05/21 22:59
设置圆角,通过layer中的cornerRadius和masksToBounds即可。
自适应图片宽高比例。通过UIViewContentModeScaleAspectFit设置,注意这个UIImageView的frame就不是init中的数据了。
同样的UIImage图片放入不同frame中的UIImageView就可以实现比例缩放了。只是UIImageView的大小改变了,
首先需要加入这个库以及引用这个头文件:QuartzCore.FrameWork,以及#import <QuartzCore/QuartzCore.h>;
*/
UIImage* image = [UIImage imageNamed:@"back2.jpg"];
UIImageView* imageView1 = [[[UIImageView alloc] initWithImage:image] autorelease];
imageView1.frame = CGRectMake(0, 0, 300, 200);
imageView1.center = CGPointMake(150, 200);
//设置圆角
imageView1.layer.cornerRadius = 8;
imageView1.layer.masksToBounds = YES;
//自适应图片宽高比例
imageView1.contentMode = UIViewContentModeScaleAspectFit;
[self.view addSubview:imageView1];
//拉伸图片
CGFloat capWidth = image.size.width / 2;
CGFloat capHeight = image.size.height / 2;
UIImage* stretchableImage = [image stretchableImageWithLeftCapWidth:capWidth topCapHeight:capHeight];
UIImageView* imageView3 = [[[UIImageView alloc] initWithImage:stretchableImage] autorelease];
imageView3.frame = CGRectMake(0, 0, 300, 200);
imageView3.center = CGPointMake(150, 200);
[self.view addSubview:imageView3];
//改变frame改变
UIImageView* imageView4 = [[[UIImageView alloc] initWithImage:image] autorelease];
imageView4.frame = CGRectMake(0, 0, 300/2, 200/2);
imageView4.center = CGPointMake(150, 200);
[self.view addSubview:imageView4];
- UIImageView圆角,自适应图片宽高比例,图片拉伸,缩放比例和图片缩微图
- UIImageView圆角,自适应图片宽高比例,图片拉伸,缩放比例和图片缩微图
- UIImageView圆角,自适应图片宽高比例,图片拉伸,缩放比例和图片缩微图
- UIImageView圆角,自适应图片宽高比例,图片拉伸,缩放比例和图片缩微图
- UIImageView圆角,自适应图片宽高比例,图片拉伸,缩放比例
- UIImageView圆角,自适应图片宽高比例,图片拉伸,缩放比例
- ios图片等比例自适应UIImageview
- 图片等比例缩放,图片指定宽或高按比例缩放,图片不变形缩放
- 成比例缩放图片
- 安比例缩放图片
- 图片等比例缩放
- 图片等比例缩放
- 图片等比例缩放
- 图片等比例缩放
- 图片等比例缩放
- 图片等比例缩放
- 等比例缩放图片
- 等比例缩放图片
- HDU 4634 Swipe Bo (搜索)
- 超级楼梯
- iOS: NSFileHandle的方法readDataOfLength:
- 浅谈Linux的内存管理机制
- c++ 拷贝构造练习
- UIImageView圆角,自适应图片宽高比例,图片拉伸,缩放比例
- iOS: NSFileHandle的方法readDataToEndOfFile
- hdu 4632 Palindrome subsequence 多校第四场
- Android开发之Thread类分析
- 2013 多校联合4 1011 Fliping game (hdu 4642)
- Android实用问题汇总
- iOS: NSFileHandle的方法seekToEndOfFile
- VC调用DLL
- UpdateSourceTrigger Property in WPF Binding