最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

iOS開(kāi)發(fā)實(shí)現(xiàn)UIImageView的分類

 更新時(shí)間:2019年01月23日 15:44:57   作者:夕陽(yáng)下的守望者  
這篇文章主要為大家詳細(xì)介紹了iOS開(kāi)發(fā)實(shí)現(xiàn)UIImageView的分類,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了iOS實(shí)現(xiàn)UIImageView的分類代碼,供大家參考,具體內(nèi)容如下

一.Objective-C版

.h文件

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
 
/**
 * 這個(gè)分類為UIImageView添加一些有用的方法
 */
@interface UIImageView (WLKit)
 
/**
 * 創(chuàng)建一個(gè)UIImageView
 *
 * @param image UIImageView的圖片
 * @param rect UIImageView的坐標(biāo)
 *
 * @return 返回一個(gè)UIImageView
 */
+ (instancetype _Nonnull)imageViewWithImage:(UIImage *_Nonnull)image
                   frame:(CGRect)rect;
 
/**
 * 創(chuàng)建一個(gè)UIImageView
 *
 * @param image UIImageView的圖片
 * @param size  UIImageView的大小
 * @param center UIImageView的中心
 *
 * @return 返回一個(gè)UIImageView
 */
+ (instancetype _Nonnull)imageViewWithImage:(UIImage *_Nonnull)image
                    size:(CGSize)size
                   center:(CGPoint)center;
 
/**
 * 創(chuàng)建一個(gè)UIImageView
 *
 * @param image UIImageView的圖片
 * @param center UIImageView的中心
 *
 * @return Returns the created UIImageView
 */
+ (instancetype _Nonnull)imageViewWithImage:(UIImage *_Nonnull)image
                   center:(CGPoint)center;
 
/**
 * Create an UIImageView with an image and use it as a template with the given color
 *
 * @param image   UIImageView image
 * @param tintColor UIImageView tint color
 *
 * @return Returns the created UIImageView
 */
+ (instancetype _Nonnull)imageViewWithImageAsTemplate:(UIImage *_Nonnull)image
                      tintColor:(UIColor *_Nonnull)tintColor;
 
/**
 * Create a drop shadow effect
 *
 * @param color  Shadow's color
 * @param radius Shadow's radius
 * @param offset Shadow's offset
 * @param opacity Shadow's opacity
 */
- (void)setImageShadowColor:(UIColor *_Nonnull)color
           radius:(CGFloat)radius
           offset:(CGSize)offset
          opacity:(CGFloat)opacity;
 
/**
 * Mask the current UIImageView with an UIImage
 *
 * @param image The mask UIImage
 */
- (void)setMaskImage:(UIImage *_Nonnull)image;
 
@end

.m文件

#import "UIImageView+WLKit.h"
 
@implementation UIImageView (WLKit)
 
+ (instancetype _Nonnull)imageViewWithImage:(UIImage *_Nonnull)image frame:(CGRect)rect
{
  UIImageView *_image = [[UIImageView alloc] init];
  [_image setFrame:rect];
  [_image setImage:image];
  return _image;
}
 
+ (instancetype _Nonnull)imageViewWithImage:(UIImage *_Nonnull)image size:(CGSize)size center:(CGPoint)center
{
  UIImageView *_image = [[UIImageView alloc] init];
  [_image setFrame:CGRectMake(0, 0, size.width, size.height)];
  [_image setImage:image];
  [_image setCenter:center];
  return _image;
}
 
+ (instancetype _Nonnull)imageViewWithImage:(UIImage *_Nonnull)image center:(CGPoint)center
{
  UIImageView *_image = [[UIImageView alloc] init];
  [_image setFrame:CGRectMake(0, 0, image.size.width, image.size.height)];
  [_image setImage:image];
  [_image setCenter:center];
  return _image;
}
 
+ (instancetype _Nonnull)imageViewWithImageAsTemplate:(UIImage *_Nonnull)image tintColor:(UIColor *_Nonnull)tintColor
{
  UIImageView *_image = [[UIImageView alloc] init];
  image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
  [_image setImage:image];
  [_image setTintColor:tintColor];
  return _image;
}
 
- (void)setImageShadowColor:(UIColor *_Nonnull)color radius:(CGFloat)radius offset:(CGSize)offset opacity:(CGFloat)opacity
{
  self.layer.shadowColor = color.CGColor;
  self.layer.shadowRadius = radius;
  self.layer.shadowOffset = offset;
  self.layer.shadowOpacity = opacity;
  self.clipsToBounds = NO;
}
 
- (void)setMaskImage:(UIImage *_Nonnull)image
{
  CALayer *mask = [CALayer layer];
  mask.contents = (id)[image CGImage];
  mask.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
  self.layer.mask = mask;
  self.layer.masksToBounds = YES;
}
 
- (void)setAlpha:(CGFloat)alpha
{
  if ([self.superview isKindOfClass:[UITableView class]]) {
    if (self.superview.tag == 836913) {
      if (alpha == 0 && self.autoresizingMask == UIViewAutoresizingFlexibleLeftMargin) {
        if (self.frame.size.width < 10 && self.frame.size.height > self.frame.size.width) {
          UIScrollView *sc = (UIScrollView*)self.superview;
          if (sc.frame.size.height < sc.contentSize.height) {
            [super setAlpha:0.5];
            return;
          }
        }
      }
    }
    
    if (self.superview.tag == 836914) {
      if (alpha == 0 && self.autoresizingMask == UIViewAutoresizingFlexibleTopMargin) {
        if (self.frame.size.height < 10 && self.frame.size.height < self.frame.size.width) {
          UIScrollView *sc = (UIScrollView*)self.superview;
          if (sc.frame.size.width < sc.contentSize.width) {
            return;
          }
        }
      }
    }
  }
  
  [super setAlpha:alpha];
}
@end

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • iOS如何定義名為任意的變量詳解

    iOS如何定義名為任意的變量詳解

    這篇文章主要給大家介紹了關(guān)于iOS如何定義名為任意的變量的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)各位iOS開(kāi)發(fā)者們具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧。
    2018-05-05
  • iOS 定制多樣式二維碼

    iOS 定制多樣式二維碼

    最常見(jiàn)的二維碼功能包括信息獲取、網(wǎng)站跳轉(zhuǎn)、電商交易、手機(jī)支付等等,其擁有密度小、信息容量大、容錯(cuò)能力強(qiáng)、成本低、制作難度低等優(yōu)點(diǎn)。在移動(dòng)開(kāi)發(fā)中,二維碼的地位也越來(lái)越重要,掌握二維碼的基本操作是重要的本領(lǐng)之一。本文將講解iOS定制二維碼的步驟與方法。
    2017-03-03
  • CAMediaTiming ( 時(shí)間協(xié)議)詳解及實(shí)例代碼

    CAMediaTiming ( 時(shí)間協(xié)議)詳解及實(shí)例代碼

    這篇文章主要介紹了CAMediaTiming / 時(shí)間協(xié)議詳解及實(shí)例代碼的相關(guān)資料,這里附有實(shí)例代碼,幫助大家學(xué)習(xí)參考,需要的朋友可以參考下
    2016-12-12
  • CocoaPods1.9.0 安裝使用教程詳解

    CocoaPods1.9.0 安裝使用教程詳解

    CocoaPods是OS X和iOS下的一個(gè)第三類庫(kù)管理工具,這篇文章主要介紹了CocoaPods1.9.0 安裝使用,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-03-03
  • iOS WKWebView無(wú)法處理URL Scheme和App Store鏈接的問(wèn)題解決

    iOS WKWebView無(wú)法處理URL Scheme和App Store鏈接的問(wèn)題解決

    這篇文章主要給大家介紹了關(guān)于iOS WKWebView無(wú)法處理URL Scheme和App Store鏈接的問(wèn)題解決的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧。
    2018-03-03
  • iOS開(kāi)發(fā)之使用Storyboard預(yù)覽UI在不同屏幕上的運(yùn)行效果

    iOS開(kāi)發(fā)之使用Storyboard預(yù)覽UI在不同屏幕上的運(yùn)行效果

    使用Storyboard做開(kāi)發(fā)效率非常高,為了防止在團(tuán)隊(duì)中發(fā)生沖突,采取的解決辦法是負(fù)責(zé)UI開(kāi)發(fā)的同事最好每人維護(hù)一個(gè)Storyboard, 公用的組件使用輕量級(jí)的xib或者純代碼來(lái)實(shí)現(xiàn),下面小編就給大家介紹如何使用Storyboard預(yù)覽UI在不同屏幕上的運(yùn)行效果,需要的朋友可以參考下
    2015-08-08
  • ios常見(jiàn)加密解密方法(RSA、DES 、AES、MD5)

    ios常見(jiàn)加密解密方法(RSA、DES 、AES、MD5)

    本篇文章主要介紹了ios常見(jiàn)加密解密方法(RSA、DES 、AES、MD5),小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-02-02
  • iOS使用pageViewController實(shí)現(xiàn)多視圖滑動(dòng)切換

    iOS使用pageViewController實(shí)現(xiàn)多視圖滑動(dòng)切換

    這篇文章主要為大家詳細(xì)介紹了iOS使用pageViewController實(shí)現(xiàn)多視圖滑動(dòng)切換,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-06-06
  • iOS客戶端本地推送實(shí)現(xiàn)代碼

    iOS客戶端本地推送實(shí)現(xiàn)代碼

    這篇文章主要介紹了iOS客戶端本地推送實(shí)現(xiàn)代碼,并確定程序中只有一個(gè)彈出框,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-11-11
  • iOS開(kāi)發(fā)之級(jí)聯(lián)界面(推薦界面)搭建原理

    iOS開(kāi)發(fā)之級(jí)聯(lián)界面(推薦界面)搭建原理

    這篇文章主要為大家詳細(xì)介紹了iOS級(jí)聯(lián)界面(推薦界面)搭建原理,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-08-08

最新評(píng)論

高台县| 旅游| 岳普湖县| 鲁山县| 绥宁县| 永春县| 东源县| 特克斯县| 博兴县| 托克托县| 清涧县| 新宾| 佳木斯市| 上思县| 全州县| 从江县| 晋州市| 象山县| 靖宇县| 陇西县| 怀集县| 德保县| 九江市| 科尔| 万年县| 深圳市| 余干县| 赞皇县| 乌什县| 梅河口市| 武功县| 商河县| 平罗县| 南召县| 连南| 渭源县| 阜新市| 金秀| 扎兰屯市| 敦煌市| 平顶山市|