【发布时间】:2013-01-19 10:41:42
【问题描述】:
我希望能够将UIImageView 的框架绘制为红色,以便在旋转和缩放它时可以看到它。设置图层边框宽度和颜色不是我需要的,因为如果我旋转它,它也会旋转图层(而UIImageView 框架不会旋转)。这甚至可能吗?任何人都知道如何做到这一点?
【问题讨论】:
标签: ios objective-c cocoa-touch uiimageview
我希望能够将UIImageView 的框架绘制为红色,以便在旋转和缩放它时可以看到它。设置图层边框宽度和颜色不是我需要的,因为如果我旋转它,它也会旋转图层(而UIImageView 框架不会旋转)。这甚至可能吗?任何人都知道如何做到这一点?
【问题讨论】:
标签: ios objective-c cocoa-touch uiimageview
将其放置在具有红色背景色的较大 UIView 上。
UIView *redBackgroundView = [[UIView alloc] initWithFrame: … /* a bigger frame than imageView*/)];
[redBackgroundView: addSubview: imageview];
[self.view addSubview: redBackgroundView];
【讨论】:
您可以使用 UIImageView 对象的 backgroundColor 属性将 UIImageView 的背景颜色设置为红色。
【讨论】:
添加框架#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];
【讨论】: