ios - 如何在 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 中设置图像背景?
解决方案
UIViews
基本上由CALayer
's 支持,因此您可以将设置应用于其属性。
UIImage *img = [UIImage imageNamed:@"yourAssetImage"];
rootViewController.view.layer.contents = (__bridge id)img.CGImage;
推荐阅读
- rdp - WTSVirtualChannelOpenEx 有时会失败?
- typescript - 获取泛型函数的参数类型
- vue.js - 如果输入字段大于另一个字段,则禁用按钮
- javascript - 我需要在我的网站 JS 中使用 Slick Carousel 作为英雄滑块
- html - HTML5 模式:检查文本字段开头不是以空格开头
- three.js - 将多个 VR 应用程序整合到一个网页中
- css - 实现 CSS - Froms 未正确显示
- ios - 从 UIImagePickerController 获取 UIImageView 中的 Gif
- python - 如何从一个函数调用中保存变量的值并将其用于下一个函数调用?
- android-fragments - 避免片段重新创建BottomNavigationView