欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

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

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

創(chuàng)新互聯(lián)公司成立以來不斷整合自身及行業(yè)資源、不斷突破觀念以使企業(yè)策略得到完善和成熟,建立了一套“以技術(shù)為基點,以客戶需求中心、市場為導(dǎo)向”的快速反應(yīng)體系。對公司的主營項目,如中高端企業(yè)網(wǎng)站企劃 / 設(shè)計、行業(yè) / 企業(yè)門戶設(shè)計推廣、行業(yè)門戶平臺運營、成都APP應(yīng)用開發(fā)手機網(wǎng)站制作設(shè)計、微信網(wǎng)站制作、軟件開發(fā)、遂寧聯(lián)通機房等實行標(biāo)準(zhǔn)化操作,讓客戶可以直觀的預(yù)知到從創(chuàng)新互聯(lián)公司可以獲得的服務(wù)效果。

一.Objective-C版

.h文件

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
 
/**
 * 這個分類為UIImageView添加一些有用的方法
 */
@interface UIImageView (WLKit)
 
/**
 * 創(chuàng)建一個UIImageView
 *
 * @param image UIImageView的圖片
 * @param rect UIImageView的坐標(biāo)
 *
 * @return 返回一個UIImageView
 */
+ (instancetype _Nonnull)imageViewWithImage:(UIImage *_Nonnull)image
                   frame:(CGRect)rect;
 
/**
 * 創(chuàng)建一個UIImageView
 *
 * @param image UIImageView的圖片
 * @param size  UIImageView的大小
 * @param center UIImageView的中心
 *
 * @return 返回一個UIImageView
 */
+ (instancetype _Nonnull)imageViewWithImage:(UIImage *_Nonnull)image
                    size:(CGSize)size
                   center:(CGPoint)center;
 
/**
 * 創(chuàng)建一個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

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持創(chuàng)新互聯(lián)。

當(dāng)前標(biāo)題:iOS開發(fā)實現(xiàn)UIImageView的分類
文章分享:http://aaarwkj.com/article4/jesgoe.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站營銷、企業(yè)網(wǎng)站制作、Google標(biāo)簽優(yōu)化、移動網(wǎng)站建設(shè)、網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都seo排名網(wǎng)站優(yōu)化
午夜国产精品福利一二| 操老熟女一区二区三区| 亚洲欧美日韩伦理一区| 日韩av大片一区二区三区| 亚洲欧美日韩专区一区| 国产中文字幕一区久久| 国产精品黄色91熟女| 午夜剧场福利在线观看| 日本人妻精品在线观看| 日本韩国欧美在线一区| 日韩国产乱码一区中文字幕| 青青草原在线视频一区| 午夜性生活免费在线观看| 天天操夜夜操夜夜操| 国产亚洲精品免费专线视频| 久激情内射婷内射蜜桃| 中文字幕乱码熟女人妻视频 | 日韩一区二区三区无吗电影| 麻豆人妻一区二区三区| 久草热不卡的av在线| 国产91啦中文在线观看| 一区二区三区四区中文在线| 免费福利激情在线播放| 成年人在线观看免费观看| 最新中文字幕人妻少妇| 蜜桃av网站免费观看| 欧美日韩电影一区二区三区| 漂亮人妻少妇中文字幕| 99精品国产一区二区青青性色| 欧美一级午夜欧美午夜视频| 日产中文乱码字幕无线观看| 久久人热视频这里只有精品| 国产精品午夜福利天堂| 欧美日韩免费爱爱视频| 国产精品三级竹菊影视| 偷拍视频一区二区三区| 日韩欧美一区二区大片| 久久人妻久久人妻久久| 国产精品亚洲国产精品| 欧美一区二区日本国产激情| 日韩精品色av一区二区|