【问题标题】:Changing background images of UIView改变 UIView 的背景图片
【发布时间】:2010-07-01 21:56:27
【问题描述】:

我有课:

@interface UIExView : UIView {
.......
}

在另一个类中,UIExView 定义如下:

IBOutlet UIExView* exView;

exView 连接到 XIB 中的一个 View。

我将 exView 的背景图片设置为:

UIColor* bgrColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed: backgroundImageName]];
exView.backgroundColor = bgrColor;

现在我想将另一张图片更改为 exView 的背景。我做同样的事情:

UIColor* newBgrColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed: anotherBackgroundImage]];
exView.backgroundColor = newBgrColor;

它在模拟器上运行良好(背景图像更改为新的),但它在真实设备上不起作用。请分享您的经验,谢谢。

【问题讨论】:

    标签: iphone uiview uiimage


    【解决方案1】:

    也许您可以尝试在 UIExView 中添加一个 UIImageView,为 UIImageView 制作一个 IBOutlet,然后制作一些允许您更改背景图像的方法?只是一个想法。

    【讨论】:

    • 感谢 cmets。我只想知道为什么背景图片在真实设备上没有变化。
    猜你喜欢
    • 2012-04-17
    • 2018-02-03
    • 2017-10-11
    • 1970-01-01
    • 2011-12-18
    • 1970-01-01
    • 1970-01-01
    • 2012-12-01
    • 2015-03-14
    相关资源
    最近更新 更多