2013-01-19 47 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的背景色設置爲紅色。