以下是本人在瀏覽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;