YYKit三方庫(kù)常用方法,方便自己也方便別人

以下是本人在瀏覽YYKit框架時(shí)感覺(jué)可以用到的方法:

NSArray

//隨機(jī)在數(shù)組里去一個(gè)元素,傳空數(shù)組返回nil
- (nullable id)randomObject;

//通過(guò)下標(biāo)選取元素,下標(biāo)越界也不會(huì)崩潰,下標(biāo)越界返回nil
- (nullable id)objectOrNilAtIndex:(NSUInteger)index;

//將 NSString/NSNumber/NSDictionary/NSArray 轉(zhuǎn)為
json字符串,不進(jìn)行系列化(不刪除空格和回車(chē))
- (nullable NSString *)jsonStringEncoded;

//將數(shù)據(jù)進(jìn)行序列化json格式轉(zhuǎn)換,刪除空格回車(chē)等
- (nullable NSString *)jsonPrettyStringEncoded;

NSMutableArray

//刪除數(shù)組第一個(gè)元素,并把被刪除的元素返回
- (nullable id)popFirstObject;

//刪除數(shù)組最后一個(gè)元素,并把被刪除的元素返回
- (nullable id)popLastObject;

//增加一個(gè)非空類型,如果為空會(huì)報(bào)錯(cuò)
- (void)appendObject:(id)anObject;

//插入一個(gè)非空類型 到數(shù)組的首位
- (void)prependObject:(id)anObject;

//增加元素為另一個(gè)數(shù)組的全部元素,數(shù)組為空,方法不執(zhí)行
- (void)appendObjects:(NSArray *)objects;

//將要增加的數(shù)組元素放到首位,數(shù)組為空,方法不執(zhí)行
- (void)prependObjects:(NSArray *)objects;

//將數(shù)組元素添加到指定位置
- (void)insertObjects:(NSArray *)objects atIndex:(NSUInteger)index;

//將數(shù)組元素倒序輸出
- (void)reverse;

//將數(shù)組元素隨機(jī)排列
- (void)shuffle;

NSDictionary

//將字典鍵排序,升序排序
- (NSArray *)allKeysSorted;

//values根據(jù)鍵升序排序
- (NSArray *)allValuesSortedByKeys;

//判斷鍵在字典中是否有值,鍵為空返回NO,有鍵對(duì)應(yīng)的值返回YES
- (BOOL)containsObjectForKey:(id)key;

//根據(jù)數(shù)組元素返回相應(yīng)的鍵值新字典,如果鍵對(duì)應(yīng)值為空則為nil
- (NSDictionary *)entriesForKeys:(NSArray *)keys;

//將xml語(yǔ)句返回為字典,鍵值對(duì)是怎么弄得,沒(méi)看懂
+ (nullable NSDictionary *)dictionaryWithXML:(id)xmlDataOrString;

//根據(jù)鍵刪除值,并把值返回
- (nullable id)popObjectForKey:(id)aKey;

//根據(jù)字典元素刪除字典元素,并把被刪除的值以字典返回
- (NSDictionary *)popEntriesForKeys:(NSArray *)keys;

NSString

//將字符串以base64編碼
- (nullable NSString *)base64EncodedString;

//將base64編碼字符串轉(zhuǎn)為utf8編碼字符串
+ (nullable NSString *)stringWithBase64EncodedString:(NSString *)base64EncodedString;

//根據(jù)字體字號(hào)大小,設(shè)置的寬高,換行模式,返回重寫(xiě)的寬高
- (CGSize)sizeForFont:(UIFont *)font size:(CGSize)size mode:(NSLineBreakMode)lineBreakMode;

//傳入字號(hào)大小,默認(rèn)寬高字體最大,返回字體的寬
- (CGFloat)widthForFont:(UIFont *)font;

//傳入字號(hào)大小,給定寬度,不換行,返回字體高度
- (CGFloat)heightForFont:(UIFont *)font width:(CGFloat)width;

//刪除字符串中的空格和換行
- (NSString *)stringByTrim;

將字符串轉(zhuǎn)化成xxx@(scale)x;例:@"name" to @"name@2x" 在末尾追加
- (NSString *)stringByAppendingNameScale:(CGFloat)scale;

//判斷字符串中是否有空格
- (BOOL)isNotBlank;

//將字符串轉(zhuǎn)化為number類型
- (nullable NSNumber *)numberValue;

//將字符串轉(zhuǎn)化為data類型
- (nullable NSData *)dataValue;

//返回一個(gè)range 0到字符串長(zhǎng)度
- (NSRange)rangeOfAll;  

//將json字符串,轉(zhuǎn)成字典@"{"name":"a","count":2}"  => NSDictionary: @[@"name":@"a",@"count":@2]
- (nullable id)jsonValueDecoded;

NSAttributedString

//將數(shù)據(jù)歸檔成data數(shù)據(jù)
- (nullable NSData *)archiveToData;

//將data數(shù)據(jù)解檔為字符串
+ (nullable instancetype)unarchiveFromData:(NSData *)data;

//給定范圍的字體,設(shè)置字號(hào)大小
- (void)setFont:(nullable UIFont *)font range:(NSRange)range;

//設(shè)置字距
@property (nullable, nonatomic, strong, readwrite) NSNumber *kern;

//給指定范圍的字體設(shè)置字距
- (void)setKern:(nullable NSNumber *)kern range:(NSRange)range;

//整個(gè)字體的顏色
@property (nullable, nonatomic, strong, readwrite) UIColor *color;

//給定范圍設(shè)置字體顏色
- (void)setColor:(nullable UIColor *)color range:(NSRange)range;

//設(shè)置整個(gè)字體的背景顏色
@property (nullable, nonatomic, strong, readwrite) UIColor *backgroundColor;

//給定范圍設(shè)置字體的背景
- (void)setBackgroundColor:(nullable UIColor *)backgroundColor range:(NSRange)range;

//描邊,不懂怎么用
@property (nullable, nonatomic, strong, readwrite) NSNumber *strokeWidth;

//給定范圍,增加描邊
- (void)setStrokeWidth:(nullable NSNumber *)strokeWidth range:(NSRange)range;

//描邊的顏色
@property (nullable, nonatomic, strong, readwrite) UIColor *strokeColor;

//給定范圍,描邊的顏色
- (void)setStrokeColor:(nullable UIColor *)strokeColor range:(NSRange)range;

//文字陰影
@property (nullable, nonatomic, strong, readwrite) NSShadow *shadow;

//給定范圍文字的顏色
- (void)setShadow:(nullable NSShadow *)shadow range:(NSRange)range;

//刪除線的樣式
@property (nonatomic, readwrite) NSUnderlineStyle strikethroughStyle;

//給定范圍,刪除線的顏色
- (void)setStrikethroughStyle:(NSUnderlineStyle)strikethroughStyle range:(NSRange)range;

//刪除線的顏色
@property (nullable, nonatomic, strong, readwrite) UIColor *strikethroughColor;

//給定范圍刪除線的顏色
- (void)setStrikethroughColor:(nullable UIColor *)strikethroughColor range:(NSRange)range NS_AVAILABLE_IOS(7_0);

//下劃線樣式
@property (nonatomic, readwrite) NSUnderlineStyle underlineStyle;

//給定范圍,下劃線的樣式
- (void)setUnderlineStyle:(NSUnderlineStyle)underlineStyle range:(NSRange)range;

//下劃線樣式
@property (nullable, nonatomic, strong, readwrite) UIColor *underlineColor;

//給定范圍,下劃線的顏色
- (void)setUnderlineColor:(nullable UIColor *)underlineColor range:(NSRange)range;
- ....省略一些,不是太用

//文字對(duì)齊方式
@property (nonatomic, readwrite) NSTextAlignment alignment;

//給定范圍的文字對(duì)齊方式
- (void)setAlignment:(NSTextAlignment)alignment range:(NSRange)range;

---Convenience methods for text highlight---

//范圍,顏色,背景色,文字個(gè)性化設(shè)置 比如:`NSTextEffectAttributeName`等屬性,自己百度查;點(diǎn)擊事件,長(zhǎng)按事件,沒(méi)有默認(rèn)傳nil
- (void)setTextHighlightRange:(NSRange)range
                        color:(nullable UIColor *)color
              backgroundColor:(nullable UIColor *)backgroundColor
                     userInfo:(nullable NSDictionary *)userInfo
                    tapAction:(nullable YYTextAction)tapAction
              longPressAction:(nullable YYTextAction)longPressAction;

//范圍,顏色,背景色,點(diǎn)擊事件
- (void)setTextHighlightRange:(NSRange)range
                        color:(nullable UIColor *)color
              backgroundColor:(nullable UIColor *)backgroundColor
                    tapAction:(nullable YYTextAction)tapAction;

//范圍,顏色,背景色,字體個(gè)性設(shè)置
- (void)setTextHighlightRange:(NSRange)range
                        color:(nullable UIColor *)color
              backgroundColor:(nullable UIColor *)backgroundColor
                     userInfo:(nullable NSDictionary *)userInfo;

//插入字符串到指定位置
- (void)insertString:(NSString *)string atIndex:(NSUInteger)location;

//增加字符串到末尾
- (void)appendString:(NSString *)string;

NSObject

//當(dāng)前線程上調(diào)用方法,可傳參數(shù)....參數(shù)用來(lái)干啥?
- (nullable id)performSelectorWithArgs:(SEL)sel, ...;

//當(dāng)前線程延時(shí)幾秒后調(diào)用,可傳參數(shù)....參數(shù)用來(lái)干啥?
- (void)performSelectorWithArgs:(SEL)sel afterDelay:(NSTimeInterval)delay, ...;

//延時(shí)調(diào)用方法,不可傳參
- (void)performSelector:(SEL)sel afterDelay:(NSTimeInterval)delay;
...還有一些調(diào)用屬性關(guān)于線程....

//當(dāng)前類名
+ (NSString *)className;

....NSObjectForKVO一些屬性自行了解....

NSObject+YYModel

//將`NSDictionary`,`NSString`,`NSData` json格式化
+ (nullable instancetype)modelWithJSON:(id)json;

//將一個(gè)數(shù)據(jù)字典轉(zhuǎn)模型
+ (nullable instancetype)modelWithDictionary:(NSDictionary *)dictionary;

//將json數(shù)據(jù),轉(zhuǎn)為model
- (nullable id)modelToJSONObject;

//將model轉(zhuǎn)data數(shù)據(jù)
- (nullable NSData *)modelToJSONData;

//將model轉(zhuǎn)為字符串
- (nullable NSString *)modelToJSONString;

//將模型復(fù)制一份
- (nullable id)modelCopy;

//當(dāng)前模型對(duì)象與另一個(gè)模型對(duì)象是否相等;YES,相等;反之
- (BOOL)modelIsEqual:(id)model;

//模型的描素,返回一個(gè)字符串
- (NSString *)modelDescription;

NSArray (YYModel)

//將json信息轉(zhuǎn)為數(shù)組格式;例如:[{"name","Mary"},{name:"Joe"}];`cls `:[NSArray class]
+ (nullable NSArray *)modelArrayWithClass:(Class)cls json:(id)json;

//同上;
+ (nullable NSDictionary *)modelDictionaryWithClass:(Class)cls json:(id)json;

//替換屬性,比如:id替換成ID  格式如下:
+ (NSDictionary *)modelCustomPropertyMapper {
        return @{@"ID"  : @"id",
    }
+ (nullable NSDictionary<NSString *, id> *)modelCustomPropertyMapper;

//格式驗(yàn)證;比如:
@property NSString *name;
+ (NSDictionary *)modelContainerPropertyGenericClass    {
 return @{@"name" : [NSString class],
}
//用于判斷json數(shù)據(jù)格式的驗(yàn)證,保證數(shù)據(jù)正確性.->容器類型
+ (nullable NSDictionary<NSString *, id> *)modelContainerPropertyGenericClass;


//模型解析時(shí),黑白名單一下為黑白名單簡(jiǎn)介
+ (nullable NSArray<NSString *> *)modelPropertyBlacklist;

+ (nullable NSArray<NSString *> *)modelPropertyWhitelist;

//如果一個(gè) Model 需要忽略某些屬性其骄,則可以通過(guò)
實(shí)現(xiàn)協(xié)議中的 modelPropertyBlacklist 來(lái)返回屬性名列表,
YYModel 會(huì)在處理過(guò)程中忽略這些屬性;
//如果一個(gè) Model 只需要處理某些特性的屬性划滋,則可以通過(guò)實(shí)現(xiàn) 
協(xié)議中的 modelPropertyWhitelist 來(lái)返回屬性名列表,
YYModel 在處理中只會(huì)處理列表內(nèi)的屬性

NSDate

//返回當(dāng)前時(shí)間,格式自己設(shè)置;比如:[NSDate stringWithFormat:@"yyyy-MM-dd HH:mm:ss"];
- (nullable NSString *)stringWithFormat:(NSString *)format;

//將時(shí)間字符串以指定時(shí)間格式轉(zhuǎn)換為Date
+ (nullable NSDate *)dateWithString:(NSString *)dateString format:(NSString *)format;

NSTimer

//和系統(tǒng)方法無(wú)差別,將SEL事件以block封裝
+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)seconds block:(void (^)(NSTimer *timer))block repeats:(BOOL)repeats;

+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)seconds block:(void (^)(NSTimer *timer))block repeats:(BOOL)repeats;    

UIApplication

/// "Documents" folder in this app's sandbox.
@property (nonatomic, readonly) NSURL *documentsURL;
@property (nonatomic, readonly) NSString *documentsPath;
/// "Caches" folder in this app's sandbox.
@property (nonatomic, readonly) NSURL *cachesURL;
@property (nonatomic, readonly) NSString *cachesPath;

/// "Library" folder in this app's sandbox.
@property (nonatomic, readonly) NSURL *libraryURL;
@property (nonatomic, readonly) NSString *libraryPath;

/// Application's Bundle Name (show in SpringBoard).
@property (nullable, nonatomic, readonly) NSString *appBundleName;

/// Application's Bundle ID.  e.g. "com.ibireme.MyApp"
@property (nullable, nonatomic, readonly) NSString *appBundleID;

/// Application's Version.  e.g. "1.2.0"
@property (nullable, nonatomic, readonly) NSString *appVersion;

/// Application's Build number. e.g. "123"
@property (nullable, nonatomic, readonly) NSString *appBuildVersion;

/// Whether this app is being debugged (debugger attached).
@property (nonatomic, readonly) BOOL isBeingDebugged;

//網(wǎng)絡(luò)請(qǐng)求菊花旋轉(zhuǎn)
- (void)incrementNetworkActivityCount;

//網(wǎng)絡(luò)請(qǐng)求取消菊花旋轉(zhuǎn)
- (void)decrementNetworkActivityCount;

UIDevice

//以下方法或?qū)傩缘恼{(diào)用,都是基于[UIDevice currentDevice]
去實(shí)現(xiàn)的

宏定義:
//當(dāng)前設(shè)備系統(tǒng)版本號(hào)
#define kSystemVersion [UIDevice systemVersion]
//如果系統(tǒng)版本大于某系統(tǒng)號(hào)
#define kiOS8Later (kSystemVersion >= 8)

//當(dāng)前設(shè)備的系統(tǒng)版本號(hào),用了`dispatch_once_t`保證安全
+ (double)systemVersion;

/// Whether the device is iPad/iPad mini.
@property (nonatomic, readonly) BOOL isPad;

/// Whether the device is a simulator.
@property (nonatomic, readonly) BOOL isSimulator;

/// Whether the device is jailbroken(越獄).
@property (nonatomic, readonly) BOOL isJailbroken;

/// Wherher the device can make phone calls.
@property (nonatomic, readonly) BOOL canMakePhoneCalls NS_EXTENSION_UNAVAILABLE_IOS("");

//手機(jī)名字 e.g "iPhone 5s" "iPad mini 2"
@property (nullable, nonatomic, readonly) NSString *machineModelName;

/// The System's startup time.(啟動(dòng)時(shí)間)
@property (nonatomic, readonly) NSDate *systemUptime;

/// WIFI IP address of this device (can be nil). e.g. @"192.168.1.111"
@property (nullable, nonatomic, readonly) NSString *ipAddressWIFI;

/// Cell IP address of this device (can be nil). e.g. @"10.2.2.222"
@property (nullable, nonatomic, readonly) NSString *ipAddressCell;

... 還有硬盤(pán),內(nèi)存使用情況等...

UIButton

//設(shè)置button網(wǎng)絡(luò)圖片
- (void)setImageWithURL:(nullable NSURL *)imageURL
              forState:(UIControlState)state
           placeholder:(nullable UIImage *)placeholder;

//設(shè)置button網(wǎng)絡(luò)圖, options 加載過(guò)程中的操作
- (void)setImageWithURL:(nullable NSURL *)imageURL
              forState:(UIControlState)state
               options:(YYWebImageOptions)options;

//加載網(wǎng)絡(luò)圖片,button圖片加載完成后,執(zhí)行block操作
- (void)setImageWithURL:(nullable NSURL *)imageURL
              forState:(UIControlState)state
           placeholder:(nullable UIImage *)placeholder
               options:(YYWebImageOptions)options
            completion:(nullable YYWebImageCompletionBlock)completion;

//加載網(wǎng)絡(luò)背景圖片
- (void)setBackgroundImageWithURL:(nullable NSURL *)imageURL
                        forState:(UIControlState)state
                     placeholder:(nullable UIImage *)placeholder;

....背景圖加載與image加載相同,方法不同....

UIColor

//16進(jìn)制轉(zhuǎn)成色值 e.g 0x66CCFF,默認(rèn)1.0 alpha
+ (UIColor *)colorWithRGB:(uint32_t)rgbaValue;

//16進(jìn)制轉(zhuǎn)色值,可以設(shè)置透明度
+ (UIColor *)colorWithRGB:(uint32_t)rgbValue alpha:(CGFloat)alpha;  

//將一個(gè)顏色,轉(zhuǎn)為16進(jìn)制的值
- (uint32_t)rgbValue;

....獲取 紅,綠,藍(lán),飽和度,亮度,色調(diào)屬性....

UIControl

//移除當(dāng)前控制器所有taget事件
- (void)removeAllTargets;

//增加target事件,這個(gè)是增加前把之前增加的移除
- (void)setTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents;

//增加事件,block回調(diào),注意循環(huán)引用
- (void)addBlockForControlEvents:(UIControlEvents)controlEvents block:(void (^)(id sender))block;

//增加事件,把以前增加都都移除掉
- (void)setBlockForControlEvents:(UIControlEvents)controlEvents block:(void (^)(id sender))block;

UIImage

//根據(jù)Data加載GIF圖片,如果圖片較大,不能使用這個(gè)
+ (nullable UIImage *)imageWithSmallGIFData:(NSData *)data scale:(CGFloat)scale;

//判斷數(shù)據(jù)data是否可用于GIF動(dòng)畫(huà)
+ (BOOL)isAnimatedGIFData:(NSData *)data;

//判斷路徑是否可用于GIF動(dòng)畫(huà)
+ (BOOL)isAnimatedGIFFile:(NSString *)path;

//可傳data和nsstring PDF文件轉(zhuǎn)為image
+ (nullable UIImage *)imageWithPDF:(id)dataOrPath;

//將color轉(zhuǎn)為圖片,寬高1:1
+ (nullable UIImage *)imageWithColor:(UIColor *)color;

//將color轉(zhuǎn)為圖片,size 自己寫(xiě)
+ (nullable UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size;

//這個(gè)圖像是否有alpha通道
- (BOOL)hasAlphaChannel;

//將圖片裁剪,畫(huà)圓角 無(wú)邊框,無(wú)邊框顏色
- (nullable UIImage *)imageByRoundCornerRadius:(CGFloat)radius;

//圓角,邊框?qū)挾?邊框顏色
- (nullable UIImage *)imageByRoundCornerRadius:(CGFloat)radius
                               borderWidth:(CGFloat)borderWidth
                               borderColor:(nullable UIColor *)borderColor;

//圓角,邊框?qū)挾?邊框顏色,邊界線
- (nullable UIImage *)imageByRoundCornerRadius:(CGFloat)radius
                                   corners:(UIRectCorner)corners
                               borderWidth:(CGFloat)borderWidth
                               borderColor:(nullable UIColor *)borderColor
                            borderLineJoin:(CGLineJoin)borderLineJoin;

.... 圖片的旋轉(zhuǎn),平移,純色圖片的生成....

UIImageView

//圖片鏈接,默認(rèn)加載圖
- (void)setImageWithURL:(nullable NSURL *)imageURL placeholder:(nullable UIImage *)placeholder;

//加載圖片是可設(shè)置狀態(tài),e.g 狀態(tài)欄菊花.圖片漸現(xiàn),使用緩存等...
- (void)setImageWithURL:(nullable NSURL *)imageURL options:(YYWebImageOptions)options;

//`YYWebImageCompletionBlock`包括:獲取的image,url,YYWebImageFromType圖片獲取類型:內(nèi)存獲取,磁盤(pán)獲取等,`YYWebImageStage`圖片標(biāo)志:取消,失敗,完成等,
- (void)setImageWithURL:(nullable NSURL *)imageURL
           placeholder:(nullable UIImage *)placeholder
               options:(YYWebImageOptions)options
            completion:(nullable YYWebImageCompletionBlock)completion;

....還有幾個(gè)操作,此處省略....

//取消圖片請(qǐng)求
- (void)cancelCurrentImageRequest;

//將請(qǐng)求完的圖片設(shè)置為高亮,用法跟setimge一樣.
- (void)setHighlightedImageWithURL:(nullable NSURL *)imageURL placeholder:(nullable UIImage *)placeholder;

.... 高亮用法省略....

UIGestureRecognizer

// 手勢(shì)觸發(fā)事件,原來(lái)手勢(shì)是通過(guò)SEL來(lái)實(shí)現(xiàn)事件,YYKit將其封裝到block中
//初始化手勢(shì)時(shí),增加block
- (instancetype)initWithActionBlock:(void (^)(id sender))block;

//為某個(gè)手勢(shì)增加事件
- (void)addActionBlock:(void (^)(id sender))block;

//移除手勢(shì)所有的block
- (void)removeAllActionBlocks;

UIScrollView

//滾動(dòng)到指定方向,默認(rèn)有動(dòng)畫(huà)
- (void)scrollToTop;

- (void)scrollToBottom;

- (void)scrollToLeft;

- (void)scrollToRight;

//滾動(dòng)方向?yàn)橹付ǚ较?有無(wú)動(dòng)畫(huà),傳BOOL
- (void)scrollToTopAnimated:(BOOL)animated;

UITableView

//在做 TableView 的刪除,移動(dòng)等操作,需要在動(dòng)畫(huà)塊中做操作, 要不然會(huì)造成崩潰問(wèn)題
- (void)updateWithBlock:(void (^)(UITableView *tableView))block;

//滾動(dòng)到指定行,
- (void)scrollToRow:(NSUInteger)row inSection:(NSUInteger)section atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated;

//插入到指定行
- (void)insertRow:(NSUInteger)row inSection:(NSUInteger)section withRowAnimation:(UITableViewRowAnimation)animation;

//刷新某行
- (void)reloadRow:(NSUInteger)row inSection:(NSUInteger)section withRowAnimation:(UITableViewRowAnimation)animation;

//刪除某行
- (void)deleteRow:(NSUInteger)row inSection:(NSUInteger)section withRowAnimation:(UITableViewRowAnimation)animation;

//通過(guò) NSIndexPath 去插入
- (void)insertRowAtIndexPath:(NSIndexPath *)indexPath withRowAnimation:(UITableViewRowAnimation)animation;

//通過(guò) NSIndexPath 刷新
- (void)reloadRowAtIndexPath:(NSIndexPath *)indexPath withRowAnimation:(UITableViewRowAnimation)animation;

//插入分區(qū)
- (void)insertSection:(NSUInteger)section withRowAnimation:(UITableViewRowAnimation)animation;

....刷新分區(qū),刪除分區(qū),通過(guò) path 刷新,刪除,等....

//取消 tableview 中所有被選中的 cell
- (void)clearSelectedRowsAnimated:(BOOL)animated;

YYAnimatedImageView

// YYAnimatedImageView 是繼承與 UIImageView 的所以, UIImageView中加載圖片方法都使用與它.如果做動(dòng)畫(huà)視圖的話,用它比較合適.

//是否自動(dòng)播放動(dòng)畫(huà)
@property (nonatomic) BOOL autoPlayAnimatedImage;

//當(dāng)前動(dòng)畫(huà)圖片有多少幀
@property (nonatomic) NSUInteger currentAnimatedImageIndex;

//判斷當(dāng)前圖片是否正在播放動(dòng)畫(huà)
@property (nonatomic, readonly) BOOL currentIsPlayingAnimation;

CALayer

//對(duì) layer 進(jìn)行圖片
- (void)setImageWithURL:(nullable NSURL *)imageURL placeholder:(nullable UIImage *)placeholder;

//圖層加載
- (void)setImageWithURL:(nullable NSURL *)imageURL options:(YYWebImageOptions)options;  

...和 UIImage 用法差不多...

NSKeyedUnarchiver

//對(duì)文件和數(shù)據(jù)進(jìn)行解檔,與系統(tǒng)方法無(wú)異,多了對(duì)異常的返回在 block 中

//對(duì) data 數(shù)據(jù)進(jìn)行解檔
+ (nullable id)unarchiveObjectWithData:(NSData *)data
                         exception:(NSException *_Nullable *_Nullable)exception;

//對(duì)指定路徑文件進(jìn)行解檔
+ (nullable id)unarchiveObjectWithFile:(NSString *)path
                         exception:(NSException *_Nullable *_Nullable)exception;

YYImage && YYAnimatedImageView

//YYImage *image = [YYImage imageNamed:@"animation.webp"];
 YYAnimatedImageView *imageView = [YYAnimatedImageView alloc] initWithImage:image];
+ (nullable YYImage *)imageNamed:(NSString *)name; // no cache!
+ (nullable YYImage *)imageWithContentsOfFile:(NSString *)path;
+ (nullable YYImage *)imageWithData:(NSData *)data;
+ (nullable YYImage *)imageWithData:(NSData *)data scale:(CGFloat)scale;

YYLabel

//YYLable 是繼承于 UIView的類,用法與 Label 用法,屬性無(wú)差別.

//設(shè)置文字陰影,設(shè)置的同時(shí)`attributedText`屬性也被設(shè)置
@property (nullable, nonatomic, strong) UIColor *shadowColor;

//設(shè)置陰影的size 屬性,設(shè)置的同時(shí)`attributedText`屬性也被設(shè)置
@property (nonatomic) CGSize shadowOffset;

//陰影半徑
@property (nonatomic) CGFloat shadowBlurRadius;

//文字垂直方向,枚舉設(shè)置,三個(gè)方向
@property (nonatomic) YYTextVerticalAlignment textVerticalAlignment;

...還有一些屬性是關(guān)于:`YYTextParser`,`YYTextLayout`,`YYTextLinePositionModifier`,`YYTextDebugOption`,它們本身是一個(gè)類,又當(dāng)做 YYLabel 的屬性,屬于高級(jí)用法,自行了解...

//文字的點(diǎn)擊事件
@property (nullable, nonatomic, copy) YYTextAction textTapAction;

YYTextView

//YYTextView 的代理,屬性與系統(tǒng)的用法一樣.

//如果文字中有網(wǎng)址鏈接,設(shè)置鏈接樣式,默認(rèn)為 None 點(diǎn)擊事件由代理實(shí)現(xiàn)
@property (nonatomic) UIDataDetectorTypes dataDetectorTypes;

//當(dāng)“dataDetectorTypes”檢測(cè)到一系列文本時(shí)桶略,該值將是
用于修改范圍內(nèi)的原始屬性
@property (nullable, nonatomic, copy) NSDictionary<NSString *, id> *linkTextAttributes;

//設(shè)置文字的富文本屬性,更多設(shè)置看`NSAttributedString+YYText`
@property (nullable, nonatomic, copy) NSAttributedString *attributedText;

//可以查詢 layout 一些信息,只讀
@property (nullable, nonatomic, strong, readonly) YYTextLayout *textLayout;

//類似于 UITextFile 屬性,當(dāng)沒(méi)有文字輸入時(shí),顯示
@property (nullable, nonatomic, copy) NSString *placeholderText;

...還有一個(gè)顏色, font placeholder 富文本屬性...

//text 的 inset 屬性
@property (nonatomic) UIEdgeInsets textContainerInset;

//用戶是否可以對(duì)內(nèi)容進(jìn)行選擇 
@property (nonatomic, getter=isSelectable) BOOL selectable;

//對(duì)內(nèi)容是否可以編輯
@property (nonatomic, getter=isEditable) BOOL editable;

//是否允許用戶將圖片粘貼復(fù)制到文本框,默認(rèn)為 NO
@property (nonatomic) BOOL allowsPasteImage;

//是否允許將其他富文本屬性粘貼至文本框,默認(rèn)為 NO
@property (nonatomic) BOOL allowsPasteAttributedString; 
//是否允許將文本框中的富文本字符串進(jìn)行拷貝,默認(rèn)為 YES
@property (nonatomic) BOOL allowsCopyAttributedString;

//文本框是否有,撤銷,等狀態(tài),默認(rèn)為 YES
@property (nonatomic) BOOL allowsUndoAndRedo;

YYTimer

//在指定時(shí)間開(kāi)啟定時(shí)器
- (instancetype)initWithFireTime:(NSTimeInterval)start
                        interval:(NSTimeInterval)interval
                          target:(id)target
                        selector:(SEL)selector
                         repeats:(BOOL)repeats NS_DESIGNATED_INITIALIZER;
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市碉输,隨后出現(xiàn)的幾起案子跟继,更是在濱河造成了極大的恐慌,老刑警劉巖蛙婴,帶你破解...
    沈念sama閱讀 211,884評(píng)論 6 492
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件粗井,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡街图,警方通過(guò)查閱死者的電腦和手機(jī)浇衬,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,347評(píng)論 3 385
  • 文/潘曉璐 我一進(jìn)店門(mén),熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)餐济,“玉大人耘擂,你說(shuō)我怎么就攤上這事⌒跄罚” “怎么了醉冤?”我有些...
    開(kāi)封第一講書(shū)人閱讀 157,435評(píng)論 0 348
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)篙悯。 經(jīng)常有香客問(wèn)我蚁阳,道長(zhǎng),這世上最難降的妖魔是什么鸽照? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 56,509評(píng)論 1 284
  • 正文 為了忘掉前任韵吨,我火速辦了婚禮,結(jié)果婚禮上移宅,老公的妹妹穿的比我還像新娘归粉。我一直安慰自己,他們只是感情好漏峰,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,611評(píng)論 6 386
  • 文/花漫 我一把揭開(kāi)白布糠悼。 她就那樣靜靜地躺著,像睡著了一般浅乔。 火紅的嫁衣襯著肌膚如雪倔喂。 梳的紋絲不亂的頭發(fā)上,一...
    開(kāi)封第一講書(shū)人閱讀 49,837評(píng)論 1 290
  • 那天靖苇,我揣著相機(jī)與錄音席噩,去河邊找鬼。 笑死贤壁,一個(gè)胖子當(dāng)著我的面吹牛悼枢,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播脾拆,決...
    沈念sama閱讀 38,987評(píng)論 3 408
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼馒索,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼莹妒!你這毒婦竟也來(lái)了?” 一聲冷哼從身側(cè)響起绰上,我...
    開(kāi)封第一講書(shū)人閱讀 37,730評(píng)論 0 267
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤旨怠,失蹤者是張志新(化名)和其女友劉穎,沒(méi)想到半個(gè)月后蜈块,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體鉴腻,經(jīng)...
    沈念sama閱讀 44,194評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,525評(píng)論 2 327
  • 正文 我和宋清朗相戀三年百揭,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了拘哨。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 38,664評(píng)論 1 340
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡信峻,死狀恐怖倦青,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情盹舞,我是刑警寧澤产镐,帶...
    沈念sama閱讀 34,334評(píng)論 4 330
  • 正文 年R本政府宣布,位于F島的核電站踢步,受9級(jí)特大地震影響癣亚,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜获印,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,944評(píng)論 3 313
  • 文/蒙蒙 一述雾、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧兼丰,春花似錦玻孟、人聲如沸。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 30,764評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至艳丛,卻和暖如春匣掸,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背氮双。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 31,997評(píng)論 1 266
  • 我被黑心中介騙來(lái)泰國(guó)打工碰酝, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人戴差。 一個(gè)月前我還...
    沈念sama閱讀 46,389評(píng)論 2 360
  • 正文 我出身青樓送爸,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子碱璃,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,554評(píng)論 2 349

推薦閱讀更多精彩內(nèi)容

  • 1弄痹、改變 UITextField 占位文字 顏色和去掉底部白框 [_userName setValue:[UICo...
    i_MT閱讀 1,030評(píng)論 0 2
  • Swift版本點(diǎn)擊這里歡迎加入QQ群交流: 594119878最新更新日期:18-09-17 About A cu...
    ylgwhyh閱讀 25,334評(píng)論 7 249
  • 【奇談雜閱】擁有希望是美好的爽航,那什么是希望呢?希乾忱,其實(shí)是微弱讥珍、很小的意思——大音希聲。雖然微弱窄瘟、很小衷佃,卻能“望”得...
    奇妙的奇閱讀 113評(píng)論 0 0
  • 美麗的煙火 只是瞬間 流星劃過(guò)天邊 你的身影若隱若現(xiàn) 我的心越飛越遠(yuǎn) 如同落葉般的思念 永遠(yuǎn)都不會(huì)再有春天...
    逝水繁華閱讀 132評(píng)論 0 0
  • 今天下班氏义,路過(guò)解放花園的市場(chǎng),看到一個(gè)男人在賣(mài)單只的玫瑰图云,讓我突然想起以前的一些往事惯悠。 還記得第一次收玫瑰,是23...
    5809f308a769閱讀 289評(píng)論 0 0