Changing background images of UIView
I have a class :
@interface UIExView : UIView {
.......
}
In another class, UIExView is defined as following:
IBOutlet UIExView* exView;
exView is connected to an View in XIB.
I set background image of exView as:
UIColor* bgrColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed: backgroundImageName]];
exView.backgroundCol开发者_Python百科or = bgrColor;
Now I want to change another image as background of exView. I do the same things:
UIColor* newBgrColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed: anotherBackgroundImage]];
exView.backgroundColor = newBgrColor;
It work well on simulator(background image is changed to the new one) but it does not work on real device. Pls, share your experience, thanks.
Maybe you can try to add an UIImageView in the UIExView, make an IBOutlet to the UIImageView and then make some methods that allows you to change the background image? Just an idea.
精彩评论