简体   繁体   English

我如何将ios目标c中的背景图像设置为rootViewController?

[英]how can i set a background image in ios objective c to rootViewController?

i can set a background color like : rootViewController.view.backgroundColor = [UIColor colorWithRed:(35.0/255.0) green:(92.0/255.0) blue:(78.0/255.0) alpha:1];我可以设置一个背景颜色,如: rootViewController.view.backgroundColor = [UIColor colorWithRed:(35.0/255.0) green:(92.0/255.0) blue:(78.0/255.0) alpha:1];

how can i set in rootViewController an image background ?如何在 rootViewController 中设置图像背景?

UIViews are basically backed by CALayer 's so you can apply settings to its properties. UIViews基本上由CALayer支持,因此您可以将设置应用于其属性。

UIImage *img = [UIImage imageNamed:@"yourAssetImage"];
rootViewController.view.layer.contents = (__bridge id)img.CGImage;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 Objective-C 在 iOS 13 中获取 rootViewController? - How to get rootViewController in iOS 13 using Objective-C? 在 UINavigationController class 中设置 RootViewController - 目标 C - Set RootViewController in UINavigationController class - Objective C 如何在不更改图像尺寸的情况下在 iOS (iPhone/iPad) 中设置 JPG 的 DPI 信息? (目标-C) - How can I set DPI info of a JPG in iOS (iPhone/iPad) without changing the image dimensions? (Objective-C) 如何在iOS 7中使用Swift设置rootViewController - How to set the rootViewController with Swift, iOS 7 ios) Objective-c 如何在分组表中添加背景图片 - ios) Objective-c How to add a background image in the grouped table 在Objective-C中设置Button的背景图像 - Set background image of Button in Objective-C 如何在iOS8 Objective C中使用图像设置UIPageControl? - How to set UIPageControl with image in iOS8 Objective c? 如何快速从UIViewController设置rootViewController? - How can I set the rootViewController from my UIViewController in swift? 如何在 Objective-C 中设置 Amazon Amplify iOS? - How can I set up Amazon Amplify iOS in Objective-C? iOS在Objective-C中登录/注销过程后更改rootViewController - iOS Changing rootViewController after login / logout process in Objective-C
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM