• <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

        时间:2024-04-15
        • <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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:目标 - C:从 URL 加载图像? 下一篇:像在 iMessage 中一样在 Uitextview 中添加 UIImageview

                  相关文章

                2. <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>
                  1. <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>