代碼塊(Code Snippet)

lzlGetInit

- (instancetype)init {
    
    if (self == [super init]) {
        
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    
}

lzlGetCancelButton

- (void)cancelButtonAction {
    
    NSLog(@"%s",__FUNCTION__);
}

- (UIButton *)cancelButton  {
    if (!_cancelButton) {
        _cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_cancelButton setTitle:@"取消" forState:UIControlStateNormal];
        [_cancelButton setTitleColor:[UIColor hexStringToColor:@"#FFFFFF"] forState:UIControlStateNormal];
        _cancelButton.backgroundColor = [UIColor hexStringToColor:@"#A7A7A7"];
        _cancelButton.layer.cornerRadius = 17.5;
        _cancelButton.titleLabel.font = [UIFont systemFontOfSize:14];
        [_cancelButton addTarget:self action:@selector(cancelButtonAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _cancelButton;
}

lzlGetGlobalQueue

dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);

lzlGetNavigationController

- (void)setupUI {
    
    ViewController * vc = [[ViewController alloc] init];
    vc.view.backgroundColor = [UIColor whiteColor];
    UINavigationController * NC = [self addChildVc:vc title:@"" image:@"" selectedImage:@""];
    self.viewControllers = @[NC];
}

#pragma mark - 添加子控制器  設(shè)置圖片
/**
 *  添加一個(gè)子控制器
 *
 *  @param childVc       子控制器
 *  @param title         標(biāo)題
 *  @param image         圖片
 *  @param selectedImage 選中的圖片
 */
- (UINavigationController*)addChildVc:(UIViewController *)childVc title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage {
    
    // 設(shè)置子控制器的文字
    childVc.title = title; // 同時(shí)設(shè)置tabbar和navigationBar的文字
    
    // 設(shè)置子控制器的圖片
    childVc.tabBarItem.image = [[UIImage imageNamed:image] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    childVc.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImage]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    //未選中字體顏色  system為系統(tǒng)字體
    [childVc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor lightGrayColor],NSFontAttributeName:[UIFont fontWithName:nil size:13]} forState:UIControlStateNormal];
    
    //選中字體顏色
    [childVc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blackColor],NSFontAttributeName:[UIFont fontWithName:nil size:13]} forState:UIControlStateSelected];
    
    // 先給外面?zhèn)鬟M(jìn)來的小控制器 包裝 一個(gè)導(dǎo)航控制器
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:childVc];
    return nav;
}

#pragma mark - 類的初始化方法枫弟,只有第一次使用類的時(shí)候會(huì)調(diào)用一次該方法
+ (void)initialize {
    
    //tabbar去掉頂部黑線
    [[UITabBar appearance] setBackgroundImage:[UIImage new]];
    [[UITabBar appearance] setShadowImage:[UIImage new]];
    [[UITabBar appearance] setBarTintColor:[UIColor whiteColor]];
}

lzlGetWindowScene

UIWindowScene *windowScene = (UIWindowScene *)scene;
    self.window = [[UIWindow alloc] initWithWindowScene:windowScene];
    self.window.frame = windowScene.coordinateSpace.bounds;
    ViewController *vc = [[ViewController alloc] init];
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
    nav.view.backgroundColor = [UIColor whiteColor];
    self.window.rootViewController = nav;
    [self.window makeKeyAndVisible];

lzlGetAlertController

UIAlertController *alertCTL = [UIAlertController alertControllerWithTitle:@"溫馨提示" message:@"單筆交易金額不能超過五萬!" preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"確定" style:UIAlertActionStyleDefault handler:nil];
[alertCTL addAction:cancelAction];
[alertCTL addAction:okAction];
[self presentViewController:alertCTL animated:YES completion:nil];

lzlGetASButton

- (ASButton *)<#asbutton#> {
    if (!<#_asbutton#>) {
        <#_asbutton#> = [[ASButton alloc] init];
        <#_asbutton#>.buttonStyle = ASButtonImageRight;
        <#_asbutton#>.padding = 5;
        <#_asbutton#>.backgroundColor = KMainLoginOutColor;
        <#_asbutton#>.layer.cornerRadius = 17.5;
        <#_asbutton#>.titleLabel.font = [UIFont systemFontOfSize:14];
        [<#_asbutton#> setImage:[UIImage imageNamed:@"click_to_go_official_website_button_icon"] forState:UIControlStateNormal];
        [<#_asbutton#> setTitle:@"點(diǎn)擊前往官網(wǎng)" forState:UIControlStateNormal];
        [<#_asbutton#> addTarget:self action:@selector(clickToGoOfficialWebsiteButtonAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return <#_asbutton#>;
}

lzlGetBackFunction

- (void)backAction{
    
    [self dismissViewControllerAnimated:YES completion:nil];
}

lzlGetBlockOperation

typedef void (^<# blockName #>)(<# type #> *<# name #>);

@property (nonatomic, <# type #>) void (^<# blockName #>)(<# type #> *<# name #>);

- (void)dataSourceWith<# blockName #>Operation:(void (^)(<# type #> * <# name #>))<# blockName #>Operation;

lzlGetButton

- (void)<# lzlbutton #>Action {
    
    NSLog(@"%s",__FUNCTION__);
}

- (UIButton *)<# lzlbutton #> {
    if (!_<# lzlbutton #>) {
        _<# lzlbutton #> = [[UIButton alloc] init];
        [_<# lzlbutton #> setTitleColor:<# lzlcolor #> forState:UIControlStateNormal];
        [_<# lzlbutton #> setTitle:<# title #> forState:UIControlStateNormal];
        _<# lzlbutton #>.titleLabel.font = [UIFont systemFontOfSize:<# size #>];
        [_<# lzlbutton #> addTarget:self action:@selector(<# lzlbutton #>Action) forControlEvents:UIControlEventTouchUpInside];
    }
    return _<# lzlbutton #>;
}

lzlGetCloseButton

// 關(guān)閉彈窗
- (UIButton *)closeButton  {
    if (!_closeButton) {
        _closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_closeButton setImage:[UIImage imageNamed:@"live_room_popoview_close_img"] forState:UIControlStateNormal];
        [_closeButton addTarget:self action:@selector(closeButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _closeButton;
}

lzlGetClosewhitebutton

- (UIButton *)closeButton  {
    if (!_closeButton) {
        _closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_closeButton setImage:[UIImage imageNamed:@"live_room_popoview_close_img_white"] forState:UIControlStateNormal];
        [_closeButton addTarget:self action:@selector(closeButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _closeButton;
}

lzlGetCollectionViewDelegate

#pragma mark- UIColloctionViewDelegate
// 返回組數(shù)
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    
    return 3;
}

// 返回每組當(dāng)中所有的元素個(gè)數(shù)
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    
    return 12;
}

// 返回每個(gè)元素所使用的UICollectionViewCell對(duì)象
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    //去復(fù)用隊(duì)列中查找cell
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
    //改變背景色
    cell.backgroundColor = [UIColor orangeColor];
    
    return cell;
}

// 修改每一個(gè)item的寬度和高度
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    return CGSizeMake(100, 100);
}

// 返回每一組元素跟屏幕4個(gè)邊界的距離(上定躏,左,下牺陶,右)
-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
    
    //創(chuàng)建一個(gè)UIEdgeInsets的結(jié)構(gòu)體
    return UIEdgeInsetsMake(10, 10, 10, 10);
}

// 返回頭部視圖的寬和高
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section {
    
    //注意:如果是豎直滑動(dòng)爷辱,則只有高度有效鳄乏,如果是水平滑動(dòng)唠亚,則只有寬度有效
    return CGSizeMake(50, 50);
}

// 返回頭部和尾部視圖所使用的UICollectionReusableView對(duì)象
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
    
    //由于頭部和尾部視圖的實(shí)例化都需要調(diào)用此方法,所以需要通過kind判斷生成的是頭部視圖還是尾部視圖
    if ([kind isEqualToString:UICollectionElementKindSectionHeader]) {
        //表示需要?jiǎng)?chuàng)建頭部視圖
        //復(fù)用形式創(chuàng)建頭部視圖
        UICollectionReusableView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"header" forIndexPath:indexPath];
        //改變背景色
        headerView.backgroundColor = [UIColor greenColor];
        
        return headerView;
    }
    return nil;
}

// 選中某一個(gè)item
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    
    NSLog(@"第%ld組第%ld個(gè)",indexPath.section,indexPath.item);
}

// 效果同layout.minimumLineSpacing,二選一
//- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
//
//}

// 效果同layout.minimumInteritemSpacing,二選一
//- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
//
//
//}

lzlGetFunction

- (<# type #>)<# functionName #>{
    
    <# Initialization code #>
}

lzlGetDocument

#pragma mark- 獲取沙盒路徑

/// Document:
- (NSString *)getDocumentPathFunction {
    
    NSString *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).lastObject;
    
    return path;
}

/// Library:
- (NSString *)getLibraryPathFunction {
    
    NSString *path = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES).lastObject;
    
    return path;
}

/// Caches:
- (NSString *)getCachesPathFunction {
    
    NSString *path = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).lastObject;
    
    return path;
}

/// Preferences:
- (NSString *)getPreferencesPathFunction {
    
    NSString *path = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES).lastObject stringByAppendingPathComponent:@"Preferences"];
    
    return path;
}

/// Temp:
- (NSString *)getTempPathFunction {
    
    NSString *path = NSTemporaryDirectory();
    
    return path;
}

lzlGetInitCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        <# Initialization code #>
    }
    return self;
}

lzlGetCollectionView

- (UICollectionView *)collectionView {
    if (!_collectionView) {
        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
        //        layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        layout.minimumInteritemSpacing = 40;
        layout.minimumLineSpacing = 5;
        _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
        _collectionView.delegate = self;
        _collectionView.dataSource = self;
        _collectionView.bounces = YES;
        _collectionView.showsVerticalScrollIndicator = NO;
        _collectionView.showsHorizontalScrollIndicator = NO;
        _collectionView.userInteractionEnabled = YES;
        _collectionView.backgroundColor = [UIColor clearColor];
        
        // 默認(rèn)選中第一個(gè)元素
        [_collectionView selectItemAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0] animated:YES scrollPosition:UICollectionViewScrollPositionNone];
        
        
        [_collectionView registerClass:[ASCollectionViewCell class] forCellWithReuseIdentifier:[ASCollectionViewCell cellIdentifier]];
    }
    return _collectionView;
}

lzlGetTypeNameWithDict

- (instancetype)init<# TypeName #>WithDict:(NSDictionary *)dict {
    if (self = [super init]) {
        [self setValuesForKeysWithDictionary:dict];
    }
    return self;
}

+ (instancetype)<# typeName #>WithDict:(NSDictionary *)dict {
    return [[self alloc] init<# TypeName #>WithDict:dict];
}

lzlGetInitWithFrame

- (instancetype)initWithFrame:(CGRect)frame {
    
    if (self = [super initWithFrame:frame]) {
        
    }
    return self;
}

lzlGetKeyWindow

+ (UIWindow *)keyWindow {
    
    UIWindow *foundWindow = nil;
    NSArray *windows = [[UIApplication sharedApplication] windows];
    for (UIWindow *window in windows) {
        if (window.isKeyWindow) {
            foundWindow = window;
            break;
        }
    }
    return foundWindow;
}

lzlGetKVC

- (void)setValuesForKeysWithDictionary:(NSDictionary *)keyedValues {
    // 遍歷字典
    for (NSString *key in keyedValues) {
        [self setValue:keyedValues[key] forKey:key];
    }
}

// 重寫
- (void)setValue:(id)value forKey:(NSString *)key {
    
    if ([value isKindOfClass:[NSNumber class]]) {
        [self setValue:[NSString stringWithFormat:@"%@",value] forKey:key];
    } else if ([value isKindOfClass:[NSNull class]]) {
        [self setValue:nil forKey:key];
    } else {
        [super setValue:value forKey:key];
    }
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    
    if ([key isEqualToString:@"description"]) {
        [self setValue:value forKey:@"myDescription"];
    } else {
        NSLog(@"未找到對(duì)應(yīng)的key值:%@",key);
    }
}

- (id)valueForUndefinedKey:(NSString *)key {
    NSLog(@"未找到對(duì)應(yīng)的key值:%@",key);
    return nil;
}

lzlGetLazying

- <# name #>{
    if (!_<# name #>) {
        _<# name #> = [[<# type #> alloc] init];
    }
    return _<# name #>;
}

lzlGetLogFuncation

NSLog(@"%s",__FUNCTION__);

lzlGetLogPrint

NSLog(@"¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥");

lzlGetLogXing

NSLog(@"******************************************************");

lzlGetMark

#pragma mark-

lzlGetPickerViewDelegate

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
    
    return 1;
}

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
    
    return 3;
}

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
    
    return [NSString stringWithFormat:@"row number %ld",row];
}

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
    
    self.myLabel.text = [NSString stringWithFormat:@"row number %ld",row];
}

lzlGetPopoview

@interface <#popoview#> ()

@property (nonatomic, strong) UIView * mainBGView;

@property (nonatomic, strong) UIView * contentBGView;

@property (nonatomic, strong) UIButton * closeButton;

@end

static <#popoview#> *<#_popoviewManager#> = nil;

@implementation <#popoview#>

- (instancetype)<#popoview#> {
    if (self == [super init]) {
        [self setupUI];
    }
    return self;
}

+ (instancetype)<#popoview#> {
    if (<#_popoviewManager#> == nil) {
        <#_popoviewManager#> = [[self alloc] <#popoview#>];
        <#_popoviewManager#>.frame = [UIScreen mainScreen].bounds;
        <#_popoviewManager#>.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.6];
        UIWindow *keyWindow = [ASKeyWindow keyWindow];
        [keyWindow addSubview:<#_popoviewManager#>];
    }
    return <#_popoviewManager#>;
}

- (void)setupUI {
    
    [self addSubview:self.mainBGView];
    [self.mainBGView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.mas_equalTo(self);
        make.size.mas_equalTo(CGSizeMake(780, 520));
    }];
    
    [self.mainBGView addSubview:self.contentBGView];
    [self.contentBGView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.mainBGView).offset(15);
        make.top.mas_equalTo(self.mainBGView).offset(15);
        make.right.mas_equalTo(self.mainBGView).offset(-15);
        make.bottom.mas_equalTo(self.mainBGView).offset(-15);
    }];
    
    [self.contentBGView addSubview:self.closeButton];
    [self.closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.contentBGView).offset(-11);
        make.top.mas_equalTo(self.contentBGView).offset(11);
        make.size.mas_equalTo(CGSizeMake(16.5, 16.5));
    }];
    
}

#pragma mark- function

+ (void)hiddenChangeTextbookOrCoursewarePopoView {
    
    [_changeTextbookOrCoursewarePopoViewManager removeFromSuperview];
    _changeTextbookOrCoursewarePopoViewManager = nil;
}

- (void)hiddenChangeTextbookOrCoursewarePopoView {
    
    [_changeTextbookOrCoursewarePopoViewManager removeFromSuperview];
    _changeTextbookOrCoursewarePopoViewManager = nil;
}

- (void)closeButtonAction {
    
    [self hiddenChangeTextbookOrCoursewarePopoView];
}

#pragma mark- lazying

- (UIView *)mainBGView {
    if (!_mainBGView) {
        _mainBGView = [[UIView alloc] init];
        _mainBGView.layer.cornerRadius = 15;
        _mainBGView.backgroundColor = KMainBorderColor;
    }
    return _mainBGView;
}

- (UIView *)contentBGView {
    if (!_contentBGView) {
        _contentBGView = [[UIView alloc] init];
        _contentBGView.layer.cornerRadius = 10;
        _contentBGView.backgroundColor = KMainBGViewColor;
    }
    return _contentBGView;
}

// 關(guān)閉彈窗
- (UIButton *)closeButton  {
    if (!_closeButton) {
        _closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_closeButton setImage:[UIImage imageNamed:@"live_room_popoview_close_img"] forState:UIControlStateNormal];
        [_closeButton addTarget:self action:@selector(closeButtonAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _closeButton;
}

lzlGetPrefixHeader_pch

// 項(xiàng)目通用配置頭文件

#pragma mark-  APP
#define kAppBundleName       [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]
#define kAppDisplayName   [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]
#define kAppVersion    [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]
#define kAppBundleVersion    [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]
// 手機(jī)序列號(hào)  設(shè)備唯一標(biāo)識(shí)符
#define kUUIDString  [[[UIDevice currentDevice] identifierForVendor] UUIDString]
// 手機(jī)別名: 用戶定義的名稱
#define kUserPhoneName     [[UIDevice currentDevice] name]
// 設(shè)備名稱
#define kDeviceName     [[UIDevice currentDevice] systemName]
// 手機(jī)系統(tǒng)版本
#define kPhoneVersion     [[UIDevice currentDevice] systemVersion]
// 手機(jī)型號(hào)
#define kPhoneModel     [[UIDevice currentDevice] model]
// 地方型號(hào)  (國(guó)際化區(qū)域名稱)
#define kLocalPhoneModel     [[UIDevice currentDevice] localizedModel]




#pragma mark- 日志打印輸出

#ifdef DEBUG
#define ADLog(...) NSLog(__VA_ARGS__)
#else
#define ADLog(...) do {} while (0)
#endif

#ifdef DEBUG
#define DLog(...) NSLog(__VA_ARGS__)
#define debugMethod() NSLog(@"%s", __func__)
#else
#define DLog(...)
#define debugMethod()
#endif

/** 調(diào)試模式下輸入NSLog,發(fā)布后不再輸入  (打印信息包括 文件名 + 打印行數(shù) + 打印方法 + 打印內(nèi)容) */
#if DEBUG
#define Log(FORMAT, ...) fprintf(stderr, "\n----------------- NSLog start -----------------\n[文件名:%s] : [行號(hào):%d]\n[函數(shù)名:%s]\n%s\n----------------- NSLog end -------------------\n", [[[NSString stringWithUTF8String: __FILE__] lastPathComponent] UTF8String], __LINE__, __PRETTY_FUNCTION__, [[NSString stringWithFormat: FORMAT, ## __VA_ARGS__] UTF8String]);
#else
#define Log(FORMAT, ...)
#define debugMethod()
#endif


#pragma mark-  https
#define HTTPS_MACRO 1
#define sHttp      HTTPS_MACRO ? @"https" : @"http"
#define sPort      HTTPS_MACRO ? @"443"   : @"80"
#define isHTTPS    HTTPS_MACRO ? @"YES"   : @"NO"


#pragma mark-  色值設(shè)置
#define RGBColor(rgb) ([[UIColor alloc] initWithRed:(((rgb >> 16) & 0xff) / 255.0f) green:(((rgb >> 8) & 0xff) / 255.0f) blue:(((rgb) & 0xff) / 255.0f) alpha:1.0f])
#define RGBAColor(rgb,a) ([[UIColor alloc] initWithRed:(((rgb >> 16) & 0xff) / 255.0f) green:(((rgb >> 8) & 0xff) / 255.0f) blue:(((rgb) & 0xff) / 255.0f) alpha:a])
#define HexRGBColor(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
#define RGB(r, g, b) [UIColor colorWithRed:((r) / 255.0) green:((g) / 255.0) blue:((b) / 255.0) alpha:1.0]
#define RGBA(r, g, b, a) [UIColor colorWithRed:((r) / 255.0) green:((g) / 255.0) blue:((b) / 255.0) alpha:(a)]
#define rgba(r, g, b, a) [UIColor colorWithRed:((r) / 255.0) green:((g) / 255.0) blue:((b) / 255.0) alpha:(a)]



#pragma mark-  屏幕 尺寸
#define ScreenH [UIScreen mainScreen].bounds.size.height
#define ScreenW [UIScreen mainScreen].bounds.size.width


#pragma mark- iPhone iPad iPhone_X的判斷
#define IS_IPHONE ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone)
#define IS_IPHONE_X ((ScreenW == 812.0f) ? YES : NO)
#define IS_IPAD ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad)


#pragma mark-  導(dǎo)航欄高度
#define ADNavHeight (IS_IPHONE ? 45 : 60)


#pragma mark-  屏幕比例恤煞,相對(duì)pad 1024 * 768
#define Proportion (ScreenH/768.0)


#pragma mark-  系統(tǒng)判定
#define iOS7 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
#define iOS7Later ([UIDevice currentDevice].systemVersion.floatValue >= 7.0f)
#define iOS8Later ([UIDevice currentDevice].systemVersion.floatValue >= 8.0f)
#define iOS9Later ([UIDevice currentDevice].systemVersion.floatValue >= 9.0f)
#define iOS9_1Later ([UIDevice currentDevice].systemVersion.floatValue >= 9.1f)
#define iOS10_0Later ([UIDevice currentDevice].systemVersion.floatValue >= 10.0f)


#pragma mark-  引用
#define ad_weakify(var)   __weak typeof(var) weakSelf = var
#define ad_strongify(var) __strong typeof(var) strongSelf = var


#pragma mark- 字符串判斷
#define ISSTRINGCLASS(IPHONESTR) ([[IPHONESTR class] isSubclassOfClass:[NSString class]] ? YES:NO) // 是否字符串
#define NOTNILSTRING(IPHONESTR) ((ISSTRINGCLASS(IPHONESTR) == YES) ? IPHONESTR:@"") // 如果不是字符串則設(shè)為空字符串
#define NOTNILSTRINGTOSTR(IPHONESTR,ToStr) ((ISSTRINGCLASS(IPHONESTR) == YES) ? IPHONESTR:ToStr)//如果不是字符串則設(shè)為指定字符串


#pragma mark - 適配處理
/** 屏幕寬高 */
#define kScreenSize           ([UIScreen mainScreen].bounds.size)
#define kScreenWidth          ([UIScreen mainScreen].bounds.size.width)
#define kScreenHeight         ([UIScreen mainScreen].bounds.size.height)

/** 相當(dāng)于4.7屏幕的比例 */
#define kGlobalRate            ([UIScreen mainScreen].bounds.size.width/375.0f)
#define kGlobalRate1            ([UIScreen mainScreen].bounds.size.width/375.0f/2)
#define kPictureBookWidthScale ([UIScreen mainScreen].bounds.size.width/667.0f)
#define kPictureBookWScale (kScreenHeight/812.0f)
#define kPictureBookHScale (kScreenWidth/812.0f)

/** 狀態(tài)欄高度 */
#define kStatusBarHeight      ([[UIApplication sharedApplication] statusBarFrame].size.height)

/** 導(dǎo)航欄高度 */
#define kNavBarHeight         44.0

/** 底部導(dǎo)航欄高度 */
#define kTabBarHeight         ([[UIApplication sharedApplication] statusBarFrame].size.height > 20 ? 83 : 49)

/** 頂部視圖高度    導(dǎo)航欄加狀態(tài)欄高度*/
#define kTopHeight            (kStatusBarHeight + kNavBarHeight)

/** 距離底部安全區(qū)域高度 */
#define kSafeAreaBottomHeight (kStatusBarHeight > 20 ? 34 : 0)


#pragma mark - 快捷設(shè)置
#define kSetFrameY(view, newY) view.frame = CGRectMake(view.frame.origin.x, newY, view.frame.size.width, view.frame.size.height)
#define kSetFrameX(view, newX) view.frame = CGRectMake(newX, view.frame.origin.y, view.frame.size.width, view.frame.size.height)
#define kSetFrameH(view, newH) view.frame = CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, newH)
#define kSetFrameW(view, newW) view.frame = CGRectMake(view.frame.origin.x, view.frame.origin.y, newW, view.frame.size.height)

lzlGetScreenWidthAndHight

#define ScreenW  [UIScreen mainScreen].bounds.size.width
#define ScreenH  [UIScreen mainScreen].bounds.size.height

lzlGetScrollViewDelegate

#pragma mark- UIScrollViewDelegate

// 準(zhǔn)備開始拖拽
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
    
    NSLog(@"scrollViewWillBeginDragging");
}

// 準(zhǔn)備停止拖拽
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset {
    
    NSLog(@"scrollViewWillEndDragging");
}

// 已經(jīng)停止拖拽
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
    
    NSLog(@"scrollViewDidEndDragging");
}

// 準(zhǔn)備開始減速
- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView {
    
    NSLog(@"scrollViewWillBeginDecelerating");
}

//已經(jīng)停止減速
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
    
    NSLog(@"偏移量為%@",NSStringFromCGPoint(scrollView.contentOffset));
    NSLog(@"scrollViewDidEndDecelerating");
}

// 滾動(dòng)過程中一直調(diào)用的代理方法
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    
    //    NSLog(@"偏移量為%@",NSStringFromCGPoint(scrollView.contentOffset));
    //    NSLog(@"scrollViewDidScroll");
}

// 允許點(diǎn)擊狀態(tài)欄滑動(dòng)到頂部
- (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView {
    
    return YES;
}

// 已經(jīng)滑動(dòng)到頂部
- (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView {
    
    //NSLog(@"scrollViewDidScrollToTop");
    UIAlertController *alertCTL = [UIAlertController alertControllerWithTitle:@"溫馨提示" message:@"已經(jīng)滑到最頂" preferredStyle:UIAlertControllerStyleAlert];
    
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
    UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"確定" style:UIAlertActionStyleDefault handler:nil];
    [alertCTL addAction:cancelAction];
    [alertCTL addAction:okAction];
    [self presentViewController:alertCTL animated:YES completion:nil];
}

lzlGetSessionDataDelegate

#pragma mark - <NSURLSessionDataDelegate>

// 1.接收到服務(wù)器的響應(yīng)
- (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveResponse:(NSURLResponse *)response completionHandler:(void (^)(NSURLSessionResponseDisposition))completionHandler {
    
    NSLog(@"%s", __func__);
    // 允許處理服務(wù)器的響應(yīng)屎勘,才會(huì)繼續(xù)接收服務(wù)器返回的數(shù)據(jù)
    completionHandler(NSURLSessionResponseAllow);
    // void (^)(NSURLSessionResponseDisposition)
}

// 2.接收到服務(wù)器的數(shù)據(jù)(可能會(huì)被調(diào)用多次)
- (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveData:(NSData *)data {
    
    NSLog(@"%s", __func__);
}

//  3.請(qǐng)求成功或者失敗(如果失敗居扒,error有值)
- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error {
    
    NSLog(@"%s", __func__);
}

lzlGetSessionDownloadDelegate

#pragma mark - <NSURLSessionDownloadDelegate>

- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error {
    
    NSLog(@"didCompleteWithError");
}

- (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didResumeAtOffset:(int64_t)fileOffset expectedTotalBytes:(int64_t)expectedTotalBytes {
    
    NSLog(@"didResumeAtOffset");
}

/**
 * 每當(dāng)寫入數(shù)據(jù)到臨時(shí)文件時(shí)概漱,就會(huì)調(diào)用一次這個(gè)方法
 * totalBytesExpectedToWrite:總大小
 * totalBytesWritten: 已經(jīng)寫入的大小
 * bytesWritten: 這次寫入多少
 */
- (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didWriteData:(int64_t)bytesWritten totalBytesWritten:(int64_t)totalBytesWritten totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite {
    
    NSLog(@"--------%f", 1.0 * totalBytesWritten / totalBytesExpectedToWrite);
}

// 下載完畢就會(huì)調(diào)用一次這個(gè)方法
- (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didFinishDownloadingToURL:(NSURL *)location {
    
    // 文件將來存放的真實(shí)路徑
    NSString *file = [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:downloadTask.response.suggestedFilename];
    
    // 剪切l(wèi)ocation的臨時(shí)文件到真實(shí)路徑
    NSFileManager *mgr = [NSFileManager defaultManager];
    [mgr moveItemAtURL:location toURL:[NSURL fileURLWithPath:file] error:nil];
}

lzlGetSetupUI

- (void)setupUI {
    
}

lzlGetSingleton

static id _instance = nil;

+ (instancetype)sharedInstance {
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _instance = [[self alloc] init];
    });
    return _instance;
}

+ (instancetype)allocWithZone:(struct _NSZone *)zone {
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _instance = [super allocWithZone:zone];
    });
    return _instance;
}

- (id)copyWithZone:(NSZone *)zone {
    
    return _instance;
}

#if __has_feature(objc_arc)
// 編譯器是ARC環(huán)境
#else
// 編譯器是MRC環(huán)境

- (oneway void)release {
    
}

- (instancetype)retain {
    
    return self;
}

- (instancetype)autorelease {
    
    return self;
}

- (NSUInteger)retainCount {
    
    return 1;
}

#endif

lzlGetSizeAttributedText

/// 計(jì)算帶有行間距的文字的Size
/// @param text 傳入的文字內(nèi)容
/// @param font 字體大小
/// @param maxSize 最大顯示尺寸
/// @param lineSpacing 設(shè)置行間距
/// @param kernAttributeName 設(shè)置字間距
- (CGSize)sizeAttributedTextWithText:(NSString *)text font:(UIFont *)font maxSize:(CGSize)maxSize lineSpacing:(CGFloat)lineSpacing kernAttributeName:(CGFloat)kernAttributeName {
    
    NSMutableParagraphStyle *paragraStyle = [[NSMutableParagraphStyle alloc] init];
    paragraStyle.lineBreakMode = NSLineBreakByCharWrapping;
    paragraStyle.alignment = NSTextAlignmentLeft;
    paragraStyle.lineSpacing = lineSpacing; // 設(shè)置行間距
    paragraStyle.hyphenationFactor = 1.0;
    paragraStyle.firstLineHeadIndent = 0.0;
    paragraStyle.paragraphSpacingBefore = 0.0;
    paragraStyle.headIndent = 0;
    paragraStyle.tailIndent = 0;
    // 設(shè)置字間距 NSKernAttributeName: @1.5f,
    NSDictionary *dic = @{
        NSFontAttributeName:font,
        NSParagraphStyleAttributeName:paragraStyle,
        NSKernAttributeName: @(kernAttributeName),
    };
    
    CGSize size = [text boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil].size;
    return size;
}

lzlGetSizeWithText

/// 計(jì)算文字尺寸
/// @param text 需要計(jì)算文字的尺寸
/// @param font 文字的字體
/// @param maxSize 文字的最大尺寸
- (CGSize)sizeWithText:(NSString *)text font:(UIFont *)font maxSize:(CGSize)maxSize {
    
    NSDictionary *attrs = @{NSFontAttributeName : font};
    return [text boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:attrs context:nil].size;
}

lzlGetTableViewDelegate

#pragma mark- UITableView代理

// 返回組數(shù)
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 3;
}

// 返回行數(shù)
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return 3;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    //復(fù)用的形式創(chuàng)建
    static NSString * const ID = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    
    cell.textLabel.text = @"大家好";
    
    return cell;
}

// 返回組頭高度
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    
    return 30;
}

// 自定義組頭視圖(必須要返回組頭高度)
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    
    UIButton *b = [UIButton buttonWithType:UIButtonTypeSystem];
    [b setTitle:[NSString stringWithFormat:@"第%ld組組頭",section] forState:UIControlStateNormal];
    b.backgroundColor = [UIColor orangeColor];
    //返回視圖的高度一般要與組頭高度一致
    b.frame = CGRectMake(0, 0, self.view.frame.size.width, 30);
    
    return b;
}

// 返回組尾高度
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    
    return 30;
}

// 自定義組尾視圖(必須要返回高度)
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 30)];
    view.backgroundColor = [UIColor blackColor];
    
    return view;
}

lzlGetTextFieldDelegate

#pragma mark- UITextFieldDelegate

// 準(zhǔn)備進(jìn)入編輯狀態(tài)
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
    
    NSLog(@"%p",textField);
    //返回NO,無法進(jìn)入編輯狀態(tài)
    return YES;
}

// 已經(jīng)進(jìn)入編輯狀態(tài)
- (void)textFieldDidBeginEditing:(UITextField *)textField {
    
}

// 準(zhǔn)備結(jié)束編輯狀態(tài)
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField {
    
    NSLog(@"textFieldShouldEndEditing:%@",textField.text);
    //返回NO喜喂,無法結(jié)束編輯狀態(tài)
    return YES;
}

// 已經(jīng)結(jié)束編輯狀態(tài)
- (void)textFieldDidEndEditing:(UITextField *)textField {
    
}

// 是否可以點(diǎn)擊清理按鈕
-(BOOL)textFieldShouldClear:(UITextField *)textField {
    
    //返回NO瓤摧,點(diǎn)擊clear按鈕無響應(yīng)
    return YES;
}

// 是否可以點(diǎn)擊return按鈕(無效)
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    
    //收鍵盤
    //移除第一響應(yīng)者
    [textField resignFirstResponder];
    return YES;
}

// 是否允許修改內(nèi)容
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
    //string
    NSLog(@"string = %@",string);

    //textField上面的內(nèi)容
    NSLog(@"textField.text = %@",textField.text);
    /*
     if ([string isEqualToString:@"h"]) {
     return NO;
     }*/
    if (textField.text.length >= 6) {

        if ([string isEqualToString:@""]) {
            return YES;
        }
        return NO;
    }
    return YES;
}

//- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
//
//    return [self validateNumber:string];
//}
//
//- (BOOL)validateNumber:(NSString*)number {
//
//    BOOL res = YES;
//    NSCharacterSet* tmpSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789"];
//    int i = 0;
//    while (i < number.length) {
//        NSString * string = [number substringWithRange:NSMakeRange(i, 1)];
//        NSRange range = [string rangeOfCharacterFromSet:tmpSet];
//        if (range.length == 0) {
//            res = NO;
//            break;
//        }
//        i++;
//    }
//    return res;
//}
//
//#define NUMBERS @"0123456789"
//- (BOOL)textField:(UITextField*)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString*)string {
//
//    NSCharacterSet*cs;
//    cs = [[NSCharacterSet characterSetWithCharactersInString:NUMBERS] invertedSet];
//    NSString*filtered = [[string componentsSeparatedByCharactersInSet:cs] componentsJoinedByString:@""];
//    BOOL basicTest = [string isEqualToString:filtered];
//    if(!basicTest) {
//
//        UIAlertController *alertCTL = [UIAlertController alertControllerWithTitle:@"溫馨提示" message:@"請(qǐng)輸入數(shù)字!" preferredStyle:UIAlertControllerStyleAlert];
//
//        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
//        UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"確定" style:UIAlertActionStyleDefault handler:nil];
//        [alertCTL addAction:cancelAction];
//        [alertCTL addAction:okAction];
//        [self presentViewController:alertCTL animated:YES completion:nil];
//
//        return NO;
//    }
//    return YES;
//}

lzlGetTypeProperty

@property (nonatomic, <# type #>) <# type #> * <# name #>;

lzlGetWeakSelf

__weak typeof(self) weakSelf = self;

lzlGetWebViewDelegate

#pragma mark - <UIWebViewDelegate>

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    
    self.backItem.enabled = webView.canGoBack;
    self.forward.enabled = webView.canGoForward;
}

- (void)webViewDidStartLoad:(UIWebView *)webView {
    
}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
        
    self.backItem.enabled = webView.canGoBack;
    self.forward.enabled = webView.canGoForward;
}

/**
 * 每當(dāng)webView即將發(fā)送一個(gè)請(qǐng)求之前,都會(huì)調(diào)用這個(gè)方法
 * 返回YES:允許加載這個(gè)請(qǐng)求
 * 返回NO:禁止加載這個(gè)請(qǐng)求
 */
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
    
    //    NSLog(@"%@", request.URL);
    if ([request.URL.absoluteString containsString:@"life"]) return NO;
    
    // JS  JavaScript
    return YES;
}

lzlGetWindow

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];

self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[[LZLViewController alloc] init]];

lzlGetAddScrollView

CGFloat viewMargin = 88;
    
    [self.view addSubview:self.scrollView];
    [self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.view).offset(viewMargin);
        make.left.right.bottom.mas_equalTo(self.view);
    }];
    
    [self.scrollView addSubview:self.contentBGView];
    [self.contentBGView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.scrollView);
        make.width.equalTo(self.scrollView);
    }];
    
    [self.contentBGView addSubview:self.mainBGView];
    [self.mainBGView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.contentBGView).offset(viewMargin);
        make.right.mas_equalTo(self.contentBGView).offset(-viewMargin);
        make.top.mas_equalTo(self.contentBGView);
        make.height.mas_equalTo(941);
        make.bottom.mas_equalTo(self.scrollView).with.offset(-20);
    }];

lzlGetCategoryRunTime

#import "ADNewViewController+ADFunction.h"
#import <objc/runtime.h>

typedef void (^blockOperation)(BOOL isVip);

@interface ADNewViewController (ADFunction)

/// 回調(diào)信息
@property (nonatomic, copy) blockOperation blockOt;

/// 是否VIP用戶
@property (nonatomic, assign) BOOL isVip;

/// 用戶信息
@property (nonatomic, copy) NSString * userMessage;

/// 圖片的尺寸大小
@property (nonatomic, assign) CGSize imageSize;

/// 改變背景顏色
- (void)changeBackgroudViewColor;

@end

static void *kADIsVipUserKey = @"kADIsVipUserKey";  // 是否VIP用戶
static void *kADUserMessageKey = @"kADUserMessageKey";  // 用戶信息
static void *kADBlockOperationKey = @"kADBlockOperationKey";  // 回調(diào)信息
static void *kADImageSizeKey = @"kADImageSizeKey";  // 圖片的尺寸大小

@implementation ADNewViewController (ADFunction)

- (void)changeBackgroudViewColor {
    
    self.isVip = !self.isVip;
    
    if (self.isVip) {
        self.view.backgroundColor = [UIColor redColor];
        self.imageSize = CGSizeMake(400, 400);
        self.userMessage = @"是VIP用戶啊";
    } else {
        self.view.backgroundColor = [UIColor yellowColor];
        self.imageSize = CGSizeMake(200, 200);
        self.userMessage = @"是普通用戶";
    }
    
    if (self.blockOt) {
        self.blockOt(self.isVip);
    }
}

#pragma mark- objc/runtime

// 回調(diào)信息
- (void)setBlockOt:(blockOperation)blockOt {
    objc_setAssociatedObject(self, kADBlockOperationKey, blockOt, OBJC_ASSOCIATION_COPY);
}
- (blockOperation)blockOt {
    return objc_getAssociatedObject(self, kADBlockOperationKey);
}

// 是否VIP用戶
- (void)setIsVip:(BOOL)isVip {
    objc_setAssociatedObject(self, kADIsVipUserKey, @(isVip), OBJC_ASSOCIATION_RETAIN);
}
- (BOOL)isVip {
    return [objc_getAssociatedObject(self, kADIsVipUserKey) boolValue];
}

// 用戶信息
- (void)setUserMessage:(NSString *)userMessage {
    objc_setAssociatedObject(self, kADIsVipUserKey, userMessage, OBJC_ASSOCIATION_RETAIN);
}
- (NSString *)userMessage {
    return objc_getAssociatedObject(self, kADUserMessageKey);
}

// 圖片的尺寸大小
- (void)setImageSize:(CGSize)imageSize {
    objc_setAssociatedObject(self, kADImageSizeKey, [NSValue valueWithCGSize:imageSize], OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- (CGSize)imageSize {
    NSValue *value = objc_getAssociatedObject(self, kADImageSizeKey);
    return value.CGSizeValue;
}

lzlGetPodfile

platform :ios,'<# vision #>'
    target "<# projectName #>" do

       pod 'Masonry'

    end

lzlGetAddTableViewCellHeader

+ (NSString *)cellIdentifier;

+ (instancetype)cellWithTableView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath;

lzlGetAddTableViewCell

+ (NSString *)cellIdentifier {
    static NSString *ID = @"<# cellIdentifier #>";
    return ID;
}

+ (instancetype)cellWithTableView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath {
    
    <# ADTableViewCell #> *cell = [tableView dequeueReusableCellWithIdentifier:[<# ADTableViewCell #> cellIdentifier] forIndexPath:indexPath];
    if (!cell) {
        cell = [[self alloc] initWithStyle:<# UITableViewCellStyleDefault #> reuseIdentifier:[<# ADTableViewCell #> cellIdentifier]];
    }
    
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    
    
}

lzlGetAddCollectionViewCellHeader

+ (NSString *)cellIdentifier;

+ (instancetype)cellWithCollectionView:(UICollectionView *)collectionView indexPath:(NSIndexPath *)indexPath;

lzlGetAddCollectionViewCell

+ (NSString *)cellIdentifier {
    static NSString *ID = @"<# cellIdentifier #>";
    return ID;
}

+ (instancetype)cellWithCollectionView:(UICollectionView *)collectionView indexPath:(NSIndexPath *)indexPath {
    
    <# ADCollectionViewCell #> *cell = [collectionView dequeueReusableCellWithReuseIdentifier:[<# ADCollectionViewCell #> cellIdentifier] forIndexPath:indexPath];
    if (!cell) {
        cell = [[self alloc] initWithFrame:CGRectZero];
    }
    return cell;
}

- (instancetype)initWithFrame:(CGRect)frame {
    
    if (self == [super initWithFrame:frame]) {
        
        [self setupUI];
    }
    return self;
}

- (void) setupUI {
    
    
}

lzlGetCurrentViewController

#pragma mark -獲取當(dāng)前屏幕顯示的ViewController

- (UIViewController *)getCurrentViewController {
    
    UIViewController *rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController;
    UIViewController *currentViewController = [self getCurrentViewControllerFromRootViewController:rootViewController];

    return currentViewController;
}

- (UIViewController *)getCurrentViewControllerFromRootViewController:(UIViewController *)rootViewController {
    
    UIViewController *currentViewController;
    if ([rootViewController presentedViewController]) {
        rootViewController = [rootViewController presentedViewController];
    }
    
    if ([rootViewController isKindOfClass:[UITabBarController class]]) {
        currentViewController = [self getCurrentViewControllerFromRootViewController:[(UITabBarController *)rootViewController selectedViewController]];
    } else if ([rootViewController isKindOfClass:[UINavigationController class]]) {
        currentViewController = [self getCurrentViewControllerFromRootViewController:[(UINavigationController *)rootViewController visibleViewController]];
    } else {
        currentViewController = rootViewController;
    }
    return currentViewController;
}

lzlGetStringWidth

/// 計(jì)算字符串長(zhǎng)度
/// @param string string
/// @param font font
- (CGFloat)getWidthWithString:(NSString *)string font:(UIFont *)font {
    NSDictionary *attrs = @{NSFontAttributeName : font};
    return [string boundingRectWithSize:CGSizeMake(0, 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:attrs context:nil].size.width;
}

lzlGetRandomColor

/// 隨機(jī)色
- (UIColor*) randomColor {
    NSInteger r = arc4random() % 255;
    NSInteger g = arc4random() % 255;
    NSInteger b = arc4random() % 255;
    return [UIColor colorWithRed:r / 255.0 green:g / 255.0 blue:b / 255.0 alpha:1];
}

lzlGetBezierPath

UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:<#CGRect#> byRoundingCorners:UIRectCornerAllCorners cornerRadii:<#CGSize#>];
CAShapeLayer *layer = [[CAShapeLayer alloc] init];
layer.frame = <#CGRect#>;
layer.path = path.CGPath;
<#propertyName#>.layer.mask = layer;
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末玉吁,一起剝皮案震驚了整個(gè)濱河市照弥,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌进副,老刑警劉巖这揣,帶你破解...
    沈念sama閱讀 221,695評(píng)論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異影斑,居然都是意外死亡给赞,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,569評(píng)論 3 399
  • 文/潘曉璐 我一進(jìn)店門矫户,熙熙樓的掌柜王于貴愁眉苦臉地迎上來片迅,“玉大人,你說我怎么就攤上這事皆辽「躺撸” “怎么了?”我有些...
    開封第一講書人閱讀 168,130評(píng)論 0 360
  • 文/不壞的土叔 我叫張陵驱闷,是天一觀的道長(zhǎng)耻台。 經(jīng)常有香客問我,道長(zhǎng)空另,這世上最難降的妖魔是什么盆耽? 我笑而不...
    開封第一講書人閱讀 59,648評(píng)論 1 297
  • 正文 為了忘掉前任,我火速辦了婚禮痹换,結(jié)果婚禮上征字,老公的妹妹穿的比我還像新娘都弹。我一直安慰自己娇豫,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 68,655評(píng)論 6 397
  • 文/花漫 我一把揭開白布畅厢。 她就那樣靜靜地躺著冯痢,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上浦楣,一...
    開封第一講書人閱讀 52,268評(píng)論 1 309
  • 那天袖肥,我揣著相機(jī)與錄音,去河邊找鬼振劳。 笑死椎组,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的历恐。 我是一名探鬼主播寸癌,決...
    沈念sama閱讀 40,835評(píng)論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼弱贼!你這毒婦竟也來了蒸苇?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,740評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤吮旅,失蹤者是張志新(化名)和其女友劉穎溪烤,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體庇勃,經(jīng)...
    沈念sama閱讀 46,286評(píng)論 1 318
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡檬嘀,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,375評(píng)論 3 340
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了匪凉。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片枪眉。...
    茶點(diǎn)故事閱讀 40,505評(píng)論 1 352
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖再层,靈堂內(nèi)的尸體忽然破棺而出扣讼,到底是詐尸還是另有隱情蚂会,我是刑警寧澤,帶...
    沈念sama閱讀 36,185評(píng)論 5 350
  • 正文 年R本政府宣布,位于F島的核電站粉渠,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏旨袒。R本人自食惡果不足惜瓣铣,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,873評(píng)論 3 333
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望碗旅。 院中可真熱鬧渡处,春花似錦、人聲如沸祟辟。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,357評(píng)論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)旧困。三九已至醇份,卻和暖如春稼锅,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背僚纷。 一陣腳步聲響...
    開封第一講書人閱讀 33,466評(píng)論 1 272
  • 我被黑心中介騙來泰國(guó)打工矩距, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人怖竭。 一個(gè)月前我還...
    沈念sama閱讀 48,921評(píng)論 3 376
  • 正文 我出身青樓锥债,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親痊臭。 傳聞我的和親對(duì)象是個(gè)殘疾皇子赞弥,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,515評(píng)論 2 359

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