• <tfoot id='4lL1E'></tfoot>
    • <bdo id='4lL1E'></bdo><ul id='4lL1E'></ul>

    <small id='4lL1E'></small><noframes id='4lL1E'>

    <legend id='4lL1E'><style id='4lL1E'><dir id='4lL1E'><q id='4lL1E'></q></dir></style></legend>
    1. <i id='4lL1E'><tr id='4lL1E'><dt id='4lL1E'><q id='4lL1E'><span id='4lL1E'><b id='4lL1E'><form id='4lL1E'><ins id='4lL1E'></ins><ul id='4lL1E'></ul><sub id='4lL1E'></sub></form><legend id='4lL1E'></legend><bdo id='4lL1E'><pre id='4lL1E'><center id='4lL1E'></center></pre></bdo></b><th id='4lL1E'></th></span></q></dt></tr></i><div id='4lL1E'><tfoot id='4lL1E'></tfoot><dl id='4lL1E'><fieldset id='4lL1E'></fieldset></dl></div>

        从 UIImageView 创建 UIImage

        Create UIImage from a UIImageView(从 UIImageView 创建 UIImage)
        • <bdo id='iNNwV'></bdo><ul id='iNNwV'></ul>
            <i id='iNNwV'><tr id='iNNwV'><dt id='iNNwV'><q id='iNNwV'><span id='iNNwV'><b id='iNNwV'><form id='iNNwV'><ins id='iNNwV'></ins><ul id='iNNwV'></ul><sub id='iNNwV'></sub></form><legend id='iNNwV'></legend><bdo id='iNNwV'><pre id='iNNwV'><center id='iNNwV'></center></pre></bdo></b><th id='iNNwV'></th></span></q></dt></tr></i><div id='iNNwV'><tfoot id='iNNwV'></tfoot><dl id='iNNwV'><fieldset id='iNNwV'></fieldset></dl></div>
                  <tbody id='iNNwV'></tbody>
                <tfoot id='iNNwV'></tfoot>

                <small id='iNNwV'></small><noframes id='iNNwV'>

                  <legend id='iNNwV'><style id='iNNwV'><dir id='iNNwV'><q id='iNNwV'></q></dir></style></legend>
                1. 本文介绍了从 UIImageView 创建 UIImage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我创建了一个 UIImageView,其中有两个 UILabel 作为它的子视图:

                  I create a UIImageView with two UILabel as subviews of it:

                   UIImageView *img=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, [[UIScreen mainScreen] bounds].size.height)];
                      img.backgroundColor=self.view.backgroundColor;
                  
                      UILabel *textOne=[[UILabel alloc]initWithFrame:CGRectMake(10, 10, 290, 250)];
                      textOne.text=_textOneLabel.text;
                      textOne.textColor=_textOneLabel.textColor;
                  
                      UILabel *textTwo = [[UILabel alloc] initWithFrame:CGRectMake(100,180,200,100)];
                      textTwo.text=_textTwoLabel.text;
                      textTwo.textColor=_textTwoLabel.textColor;
                  
                      [img addSubview:textOne];
                      [img addSubview:textTwo];
                  
                      UIImageWriteToSavedPhotosAlbum(img.image, nil, nil, nil); //img.image is null
                  

                  我想创建一个 UIImage 以将其与 UIImageView 和 2 创建的 UILabel 一起保存在相机胶卷中.img.image 返回 null,因为没有分配给 UIImageView 的图像.
                  您知道如何实现这一目标吗?

                  I want to create a UIImage to save it in the camera roll with the UIImageView and the 2 created UILabel. img.image returns null because there is no image assigned to the UIImageView.
                  Do you have an idea of how achieving that?

                  推荐答案

                  使用下面的方法将你的 UIImageView 转换为 UIImage.

                  Use below method to convert your UIImageView to UIImage.

                  UIImage *image = [self ChangeImageViewToImage:img];
                  

                  //方法

                  -(UIImage *) ChangeImageViewToImage : (UIImageView *) view{
                  
                   UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0.0);
                   [view.layer renderInContext:UIGraphicsGetCurrentContext()];
                  
                   UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
                  
                   UIGraphicsEndImageContext();
                  
                   return img;
                  
                  }
                  

                  这篇关于从 UIImageView 创建 UIImage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  what#39;s property copy means in Cocoa#39;s Framework?(like UITabBar#39;s items property)(Cocoa 框架中的属性副本是什么意思?(如 UITabBar 的 items 属性))
                  Can`t copy file from bundle to documents directory in iOS(无法将文件从捆绑包复制到 iOS 中的文档目录)
                  Automatically copy property values from one object to another of a different type but the same protocol (Objective-C)(自动将属性值从一个对象复制到另一个类型不同但协议相同的对象 (Objective-C))
                  Copy text to clipboard with iOS(使用 iOS 将文本复制到剪贴板)
                  How to copy text to clipboard/pasteboard with Swift(如何使用 Swift 将文本复制到剪贴板/粘贴板)
                  How to show the progress of copying a large file in iOS?(如何在iOS中显示复制大文件的进度?)
                      <tbody id='gJFH2'></tbody>

                  • <small id='gJFH2'></small><noframes id='gJFH2'>

                      <i id='gJFH2'><tr id='gJFH2'><dt id='gJFH2'><q id='gJFH2'><span id='gJFH2'><b id='gJFH2'><form id='gJFH2'><ins id='gJFH2'></ins><ul id='gJFH2'></ul><sub id='gJFH2'></sub></form><legend id='gJFH2'></legend><bdo id='gJFH2'><pre id='gJFH2'><center id='gJFH2'></center></pre></bdo></b><th id='gJFH2'></th></span></q></dt></tr></i><div id='gJFH2'><tfoot id='gJFH2'></tfoot><dl id='gJFH2'><fieldset id='gJFH2'></fieldset></dl></div>
                      • <tfoot id='gJFH2'></tfoot>
                        <legend id='gJFH2'><style id='gJFH2'><dir id='gJFH2'><q id='gJFH2'></q></dir></style></legend>
                          <bdo id='gJFH2'></bdo><ul id='gJFH2'></ul>