我这样的图像设置为我的观点:负载时,应用程序启动的图像 - Objective-C的
self.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"map3.jpg"]];
现在我有它的按钮操作方法。但是,如何在应用启动时直接设置它?
我这样的图像设置为我的观点:负载时,应用程序启动的图像 - Objective-C的
self.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"map3.jpg"]];
现在我有它的按钮操作方法。但是,如何在应用启动时直接设置它?
如果你想设置一个UIViewController
的看法的backgroundColor
,然后将你的代码viewDidLoad
,同样适应:
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"map3.jpg"]];
一个UIViewController
不直接拥有backgroundColor
,但其观点呢,像其他任何UIView
一样。
一种方法是将该逻辑放入您的视图控制器的-viewDidLoad方法中,用于UIImageView属性。
对不起,我写的问题是错误的。我没有imageview。我将图像设置为backgroundColor到我的视图。我应该怎么做呢? – JimmyYXA 2013-03-02 21:16:22
然后在viewDidLoad方法中设置backgroundColor。它仍然是适当的地方。 – 2013-03-02 21:49:03
的UIView
如果你是在一个UIView
类的地方在任何initWithFrame:
或initWithCoder:
initWithFrame
当实例从代码视图被调用的代码(例如UIView *myView = [[UIView alloc] initWithFrame:CGRectZero];
initWithCoder:
被称为每当UIView的是加载from XIB file。
的UIViewController
如果在UIViewController
一个共同的地方把它会在viewDidLoad
感谢它的帮助! – JimmyYXA 2013-03-02 23:00:07
尽管如此,除非实际上有图案图像(即平铺和重复的图像),否则应该使用“UIImageView”。 – 2013-03-02 23:10:46
或者'self.view.layer.contents =(id)[UIImage imageNamed:@“map3.jpg”]。CGImage;' – fumoboy007 2013-03-02 23:40:53