美文网首页iOS开发小技巧
iOS截取LaunchScreen.storyboard图片

iOS截取LaunchScreen.storyboard图片

作者: 整个夏天 | 来源:发表于2020-04-04 16:33 被阅读0次

代码

UIViewController * vc = [[UIStoryboard storyboardWithName:@"LaunchScreen" bundle:[NSBundle mainBundle]] instantiateInitialViewController];
CGRect rect = [UIScreen mainScreen].bounds;
UIGraphicsBeginImageContextWithOptions(rect.size, YES, 0.0f);
CGContextRef context = UIGraphicsGetCurrentContext();
vc.view.frame = rect;
[vc.view.layer renderInContext:context];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

注意事项

  1. storyboard的背景图片设置上下约束的时候的对象是superView,而不是Top Layout Guidebottom Layout Guide
  2. 设置约束的时候取消Constrain to margins
  3. vc.view.frame = rect;这里要根据屏幕大小设置一下view的大小,因为如果storyboard是根据iPhone8的屏幕制作的,那么此时view的大小无法满足plus以及全面屏

相关文章

  • iOS截取LaunchScreen.storyboard图片

    代码 注意事项 storyboard的背景图片设置上下约束的时候的对象是superView,而不是Top Layo...

  • iOS截取LaunchScreen.storyboard图片

    注意:控件不要使用SafeArea约束,不然获取的快照内容不准确 Swift Objective-C

  • iOS 截取tableView, scrollerView图片

    iOS 截取tableView, scrollerView图片

  • iOS 如何使用  LaunchScreen.storyboar

    iOS 如何使用 LaunchScreen.storyboard 设 置启动图片(闪屏图)[https://we...

  • 裁剪图片的特定区域

    使用 封装 参考: iOS 截取图片 部分 并生成新图片

  • iOS13 设置启动图

    iOS13之后,启动图只能用LaunchScreen.storyboard设置,并且图片直接拖到assets中,不...

  • ios截取图片

    最近有朋友遇到要截取图片中间部分展示在imageView上的问题,想着社交应用还是很可能遇到这种情况的就写下来。 ...

  • iOS 图片截取

    业务逻辑:为需要切图的view添加pan手势,定义一个需要截取范围视图的成员属性,定义一个成员变量用来记录手指的开...

  • iOS 图片截取

    入参说明:image:原始图片,rect:需要截取的位置(范围 image.bound) 出参说明:大小为 rec...

  • iOS之图片截取

    在项目中有的时候需要用截取图片的功能,有的时候还需要将特定的视图进行截取,所以就写了这个demo。1.从相册中进行...

网友评论

    本文标题:iOS截取LaunchScreen.storyboard图片

    本文链接:https://www.haomeiwen.com/subject/ajpjphtx.html