美文网首页
IOS 小功能封装

IOS 小功能封装

作者: panzhangbao | 来源:发表于2017-09-04 14:52 被阅读52次

    常用工具集合

    1. URL 中文处理
    #import "NSURL+panzhangbao.h"
    
    + (NSURL *)getURLFromChineseString:(NSString *)value;
    
    1. 视图设置圆角
    #import "UIView+panzhangbao.h"
    
    - (void)setCornerRadius:(CGFloat)radius;
    
    1. 通过 url 地址 获取一个 UIImage 类型的图片、通过颜色创建 UIImage
    #import "UIImage+panzhangbao.h"
    
    + (UIImage *)getImageFromURLString:(NSString *)urlString;
    
    + (UIImage*)createImageWithColor:(UIColor*) color;
    
    1. 时间戳转时间、获取中文字符串的大写拼音首字母
    #improt "NSString+panzhangbao.h"
    
    + (NSString *)getTimeWithTimeStamp:(NSString *)timeStampStr;
    
    + (NSString *)getFirstLetterFromChineseString:(NSString *)aString;
    
    /** 创建沙盒中文件和文件名 */
    + (NSString *)createFileWithfileWithFileName:(NSString *)fileName floderName:(NSString *)floderName;
    
    1. 微信底部弹出窗
    #import "WeChatActionSheet.h"
    
     NSArray *titleArray = @[@"标题1",@"标题2"];
        WeChatActionSheet *sheet = [WeChatActionSheet initActionSheetWithTitles:titleArray];
        [sheet setFunction:^(WeChatActionSheet *actionSheet, NSInteger index){
            if (index == WeChatCancleIndex) {
                NSLog(@"取消");
            }else{
                NSLog(@"%@", titleArray[index]);
            }
        }];
    
    1. 显示提示内容
    #import "UIViewController+HUD.h"
    
    [self showHint:@"提示内容"];
    
    1. MJRefresh - 第三方
    #import "MJRefresh.h"
    self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
            // 进入刷新状态后会自动调用这个block
            NSLog(@"下拉刷新数据");
            
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                [_tableView.mj_header endRefreshing];
            });
        }];
        // 马上进入刷新状态
        [self.tableView.mj_header beginRefreshing];
    
        
        self.tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
            NSLog(@"进入上拉加载数据");
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                [_tableView.mj_footer endRefreshing];
            });
    
        }];
    
    1. 判断手机号码格式、清理缓存、保存 UIImage 到 沙盒、倒计时多少秒
    #import "NSObject+panzhangbao.h"
    
    + (BOOL)validateMobilePnoneNumber:(NSString *)mobile;
    
    + (void)clearCache;
    
    + (void)saveUIImageToSandBox:(UIImage *)image imageName:(NSString *)imageName folderName:(NSString *)folderName;
    
    + (void)countDownTimeWithSecond:(int)second
    
    1. 自定义提示框
    #import "PanAlertView.h"
    
    PanAlertView *panAlertView = [[PanAlertView alloc] initWithTitle:@"哈哈" contentText:@"jfoijfffjifofiifiof" leftButtonTitle:@"确定" rightButtonTitle:@"取消"];
    [panAlertView showAlertView];
     panAlertView.leftBlock = ^{
            Log(@"点击了左边按钮");
        };
    panAlertView.rightBlock = ^{
            Log(@"点击了右边按钮");
        };
    
    1. 字体自适应

    Github 地址:https://github.com/panzhangbao/PanKit

    相关文章

      网友评论

          本文标题:IOS 小功能封装

          本文链接:https://www.haomeiwen.com/subject/vbdejxtx.html