首页 > 解决方案 > 如何在 ios 目标 c 中将背景图像设置为 rootViewController?

问题描述

我可以设置背景颜色:rootViewController.view.backgroundColor = [UIColor colorWithRed:(35.0/255.0) green:(92.0/255.0) blue:(78.0/255.0) alpha:1];

如何在 rootViewController 中设置图像背景?

标签: iosobjective-creact-native

解决方案


UIViews基本上由CALayer's 支持,因此您可以将设置应用于其属性。

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

推荐阅读