-1
我想把圖像放在UIView的背景中。 問題是我的視圖(subView)在主視圖中。無法在UIView背景中設置圖像?
我想把圖像放在UIView的背景中。 問題是我的視圖(subView)在主視圖中。無法在UIView背景中設置圖像?
這很簡單:
yourSubView.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"BackgroundImage.png"]];
類別:
@interface abc : UIView {
.......
}
在類定義子視圖:子視圖的
IBOutlet UIView* subView;
設置的背景圖像作爲:
UIColor* bgrColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed: backgroundImageName]];
subView.backgroundColor = bgrColor;
最後補充子視圖的視圖
[self.view addSubView:subView];