[英]Set a TTImageView as background on a TTView
我在TTView上設置imagebackground有麻煩。 這是我在互聯網上找到的代碼,但只顯示一個黑色正方形。
- (TTView *) monthBar {
if (!_monthBar) {
_monthBar = [[[TTView alloc] init] autorelease];
_monthBar.style = TTSTYLE(calendarMonthBarStyle);
_monthBar.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin;
TTImageView *imageView = [[TTImageView alloc]initWithFrame:CGRectMake(0, 0, 480, 20)];
[imageView setDefaultImage:[UIImage imageNamed:@"picture.png"]];
[self.monthBar addSubview:imageView];
[imageView release];
[self addSubview: _monthBar];
}
return _monthBar;
}
如果有人知道如何解決,請幫助我。 謝謝!
通常不需要使用_monthBar
作為_monthBar
子視圖。 您應該改用圖像作為樣式中的背景。 您的樣式似乎稱為calendarMonthBarStyle
。 您需要在其中添加引用“ picture.png”的TTImageStyle。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.