1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關(guān)咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務(wù)時(shí)間:8:30-17:00
      你可能遇到了下面的問題
      關(guān)閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
      iOS中如何實(shí)現(xiàn)imageView任意角度旋轉(zhuǎn)

      這篇文章主要介紹iOS中如何實(shí)現(xiàn)imageView任意角度旋轉(zhuǎn),文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!

      成都創(chuàng)新互聯(lián)是一家專注于成都網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)與策劃設(shè)計(jì),達(dá)川網(wǎng)站建設(shè)哪家好?成都創(chuàng)新互聯(lián)做網(wǎng)站,專注于網(wǎng)站建設(shè)十多年,網(wǎng)設(shè)計(jì)領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:達(dá)川等地區(qū)。達(dá)川做網(wǎng)站價(jià)格咨詢:18980820575

      如果需要實(shí)現(xiàn)對(duì)imageView實(shí)現(xiàn)一定角度的旋轉(zhuǎn),具體步驟是:

            1.將image轉(zhuǎn)成context。

            2.對(duì)context進(jìn)行一定角度的旋轉(zhuǎn)。

            3.將旋轉(zhuǎn)后的context 轉(zhuǎn)化成image。

      經(jīng)過這三個(gè)步驟,我們就能夠?qū)崿F(xiàn)將圖片真正的做到旋轉(zhuǎn)。

       好了,直接上代碼:

      #import"UIImage+RotateImageTool.h"
      #import
      #import
      @implementationUIImage (RotateImageTool)
      -(UIImage*)rotateImageWithDegree:(CGFloat)degree{
      //將image轉(zhuǎn)化成context
      //獲取圖片像素的寬和高
      size_t width =self.size.width*self.scale;
      size_t height =self.size.height*self.scale;
      //顏色通道為8因?yàn)?-255經(jīng)過了8個(gè)顏色通道的變化
      //每一行圖片的字節(jié)數(shù)因?yàn)槲覀儾捎玫氖茿RGB/RGBA所以字節(jié)數(shù)為width * 4
      size_t bytesPerRow =width *4;
      //圖片的透明度通道
      CGImageAlphaInfo info =kCGImageAlphaPremultipliedFirst;
      //配置context的參數(shù):
      CGContextRef context =CGBitmapContextCreate(nil, width, height,8, bytesPerRow,CGColorSpaceCreateDeviceRGB(),kCGBitmapByteOrderDefault|info);
      if(!context) {
      return nil;
      }
      //將圖片渲染到圖形上下文中
      CGContextDrawImage(context,CGRectMake(0,0, width, height),self.CGImage);
      uint8_t* data = (uint8_t*)CGBitmapContextGetData(context);
      //旋轉(zhuǎn)欠的數(shù)據(jù)
      vImage_Buffer src = { data,height,width,bytesPerRow};
      //旋轉(zhuǎn)后的數(shù)據(jù)
      vImage_Buffer dest= { data,height,width,bytesPerRow};
      //背景顏色
      Pixel_8888 backColor = {0,0,0,0};
      //填充顏色
      vImage_Flags flags = kvImageBackgroundColorFill;
      //旋轉(zhuǎn)context 
      vImageRotate_ARGB8888(&src, &dest,nil, degree *M_PI/180.f, backColor, flags);
      //將conetxt轉(zhuǎn)換成image
      CGImageRef imageRef =CGBitmapContextCreateImage(context);
      UIImage* rotateImage =[UIImageimageWithCGImage:imageRefscale:self.scaleorientation:self.imageOrientation];
      returnrotateImage;
      }

      iOS中如何實(shí)現(xiàn)imageView任意角度旋轉(zhuǎn)

      代碼中有詳細(xì)的注釋,在這里我就不過多的解釋了。感興趣的可以到github上面下載哦。

      下載地址:github.com/15221532825/ImageTool  (本地下載)

      附:iOS ImageView的Image自適應(yīng)縮放顯示全套處理方法

      // retina屏幕圖片顯示問題
      [_detailImageView setContentScaleFactor:[[UIScreen mainScreen] scale]];
      // 不規(guī)則圖片顯示
      _detailImageView.contentMode = UIViewContentModeScaleAspectFill;
      _detailImageView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
      // 圖片大于或小于顯示區(qū)域
      _detailImageView.clipsToBounds = YES;

      以上是“iOS中如何實(shí)現(xiàn)imageView任意角度旋轉(zhuǎn)”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!


      網(wǎng)頁名稱:iOS中如何實(shí)現(xiàn)imageView任意角度旋轉(zhuǎn)
      網(wǎng)址分享:http://www.ef60e0e.cn/article/gjhchh.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        嘉兴市| 历史| 水城县| 厦门市| 五原县| 泊头市| 芦溪县| 金塔县| 长兴县| 晋州市| 宁化县| 淳安县| 南木林县| 微博| 耒阳市| 视频| 平潭县| 广元市| 理塘县| 安吉县| 商南县| 曲水县| 芜湖市| 惠水县| 赤城县| 拜泉县| 南开区| 景宁| 洛宁县| 仪征市| 临沭县| 曲阜市| 兴化市| 绥化市| 眉山市| 平谷区| 兰坪| 平阴县| 遂宁市| 理塘县| 大冶市|