码迷,mamicode.com
首页 > 其他好文 > 详细

UI控件相关宏定义

时间:2018-07-30 01:06:51      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:res   设置   animate   get   ram   duration   uiview   框架   stp   

1、显示设置

  • 1.1 view圆角和边框

/** 设置view圆角和边框 */
#define kViewBorderRadius(View, Radius, Width, Color)[View.layer setCornerRadius:(Radius)];[View.layer setMasksToBounds:YES];[View.layer setBorderWidth:(Width)];[View.layer setBorderColor:[Color CGColor]]
  • 1.2 设置加载提示框

    • 1.2.1 第三方框架:Toast
    /** 第三方框架:Toast */
    #define kToast(str)              CSToastStyle *style = [[CSToastStyle alloc] initWithDefaultStyle]; [kWindow  makeToast:str duration:0.6 position:CSToastPositionCenter style:style];kWindow.userInteractionEnabled = NO; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.6 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{kWindow.userInteractionEnabled = YES;});\
    • 1.2.2 第三方框架:MBProgressHUD
    // 加载
    #define kShowNetworkActivityIndicator() [UIApplication sharedApplication].networkActivityIndicatorVisible = YES
    // 收起加载
    #define HideNetworkActivityIndicator()      [UIApplication sharedApplication].networkActivityIndicatorVisible = NO
    // 设置加载
    #define NetworkActivityIndicatorVisible(x)  [UIApplication sharedApplication].networkActivityIndicatorVisible = x
    
    #define kWindow [UIApplication sharedApplication].keyWindow
    
    #define kBackView         for (UIView *item in kWindow.subviews) { if(item.tag == 10000) { [item removeFromSuperview]; UIView * aView = [[UIView alloc] init]; aView.frame = [UIScreen mainScreen].bounds; aView.tag = 10000; aView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3]; [kWindow addSubview:aView]; } } 
    #define kShowHUDAndActivity kBackView;[MBProgressHUD showHUDAddedTo:kWindow animated:YES];kShowNetworkActivityIndicator()
    
    
    #define kHiddenHUD [MBProgressHUD hideAllHUDsForView:kWindow animated:YES]
    
    #define kRemoveBackView         for (UIView *item in kWindow.subviews) { if(item.tag == 10000) { [UIView animateWithDuration:0.4 animations:^{ item.alpha = 0.0; } completion:^(BOOL finished) { [item removeFromSuperview]; }]; } } 
    #define kHiddenHUDAndAvtivity kRemoveBackView;kHiddenHUD;HideNetworkActivityIndicator()
    

2、事件设置

/** 设置View的tag属性 */
#define VIEWWITHTAG(_OBJECT, _TAG) [_OBJECT viewWithTag : _TAG]

3、角度转换处理

/** 由角度获取弧度 有弧度获取角度 */
#define degreesToRadian(x) (M_PI * (x) / 180.0)
#define radianToDegrees(radian) (radian*180.0)/(M_PI)

UI控件相关宏定义

标签:res   设置   animate   get   ram   duration   uiview   框架   stp   

原文地址:https://www.cnblogs.com/CH520/p/9388399.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!