2013-01-19 53 views
0

我希望能够将我的UIImageView的框架绘制成红色,以便在旋转和缩放时看到它。设置图层边框的宽度和颜色并不是我所需要的,因为如果我旋转它,它也会旋转图层(而不会旋转)。这甚至有可能吗?任何人有任何线索如何做到这一点?如何绘制红色的UIImageView框架

回答

4

将它放在一个更大的具有红色背景色的UIView上。

UIView *redBackgroundView = [[UIView alloc] initWithFrame: … /* a bigger frame than imageView*/)]; 
[redBackgroundView: addSubview: imageview]; 
[self.view addSubview: redBackgroundView]; 
0

添加FramWork #import "QuartzCore/QuartzCore.h"

UIImageView *imgReport = [[UIImageView alloc] initWithFrame:CGRectMake(50, 20,250,150)] ; 
    imgReport.backgroundColor = [UIColor yellowColor]; 
    imgReport.layer.cornerRadius = 7.0; // change cornerRadius as per you requriment 
    imgReport.layer.masksToBounds = YES; 
    imgReport.layer.borderColor = [UIColor redColor].CGColor; 
    imgReport.layer.borderWidth = 5.0; 
[self.view addSubview:imgReport]; 

它可能对你有帮助:)

0

您可以使用的UIImageView对象的backgroundColor属性的UIImageView的背景色设置为红色。