【问题标题】:Set a TTImageView as background on a TTView将 TTImageView 设置为 TTView 的背景
【发布时间】:2012-01-03 19:35:26
【问题描述】:

我无法在 TTView 上设置图像背景。 这是我在互联网上找到的代码,但它只显示一个黑色方块。

- (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;
}

如果有人知道如何解决它,请帮助我。 谢谢!

【问题讨论】:

  • 你试过用 UIImageView 代替 TTImageView 吗?

标签: iphone objective-c ios coding-style three20


【解决方案1】:

通常不需要使用 imageView 作为_monthBar 的子视图。您应该使用图像作为样式中的背景。你的风格似乎被称为calendarMonthBarStyle。您需要在此处添加引用“picture.png”的 TTImageStyle。

【讨论】:

    猜你喜欢
    • 2012-09-23
    • 2019-06-13
    • 1970-01-01
    • 2012-03-05
    • 2019-10-13
    • 1970-01-01
    • 2015-11-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多