我有一个UIImageView
(红色方块),将显示一个UIImage
必须缩放(我可以接收图像大于或小于UIImageView
)。缩放之后,UIImage
的显示部分是它的中心。UIImageView内移动UIImage
我需要的是在蓝色方块中显示图像的一部分,我如何存档它?
我只能够得到图像大小(高度和宽度),但它显示原始大小,当它应该是缩放的。
self.viewIm = [[UIImageView alloc] initWithFrame:CGRectMake(100, 100, 120, 80)];
self.viewIm.backgroundColor = [UIColor greenColor];
self.viewIm.layer.borderColor = [UIColor redColor].CGColor;
self.viewIm.layer.borderWidth = 5.0;
UIImage *im = [UIImage imageNamed:@"benjen"];
self.viewIm.image = im;
self.viewIm.contentMode = UIViewContentModeScaleAspectFill;
// self.viewim.clipsToBounds = YES;
[self.view addSubview:self.viewIm];
尝试UIViewContentModeTop – Mornirch 2015-02-24 21:48:04
'UIViewContentModeTop'将没有形成规模,所以不是一种选择? – jherran 2015-02-24 21:50:36
使用UIGraphicsContext创建一个新的图像自定义大小? – Mornirch 2015-02-24 21:55:35