工程常用功能封装

来源:互联网 发布:linux sleep函数头文件 编辑:程序博客网 时间:2024/05/16 09:49

常用的插件 ,

代码提示    https://github.com/FuzzyAutocomplete/FuzzyAutocompletePlugin

变量高亮显示    https://github.com/keepyounger/HighlightSelectedString



APP中常用的宏,类别

#define Screen_Weidth  [UIScreen mainScreen].bounds.size.width#define Screen_Heigth  [UIScreen mainScreen].bounds.size.height/** *  rgb颜色转换     参数  0x0085fe */#define UIColorFrom16RGB(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]/** *  添加圆角 * *  @param __sender 加圆角的view *  @param __radius 弧度 */#define AddCornerRadius(__sender,__radius) __sender.layer.cornerRadius = __radius;\__sender.clipsToBounds = YES;\__sender.layer.borderWidth  = .5;\__sender.layer.borderColor  = [UIColor clearColor].CGColor;
#define WeakSelf __weak typeof(self) weakSelf = self ;
swift加圆角
    func addCorner(corner:CGFloat , width : CGFloat = 0.5 , color:UIColor = UIColor.clear) {                self.layer.borderColor = color.cgColor        self.layer.borderWidth = width        self.layer.cornerRadius = corner        self.clipsToBounds = true            }}




     就是写了类别,来覆盖原来方法.

             .h 文件
#import <Foundation/Foundation.h>

@interface NSArray (log)

@end

@interface NSDictionary (Log)

@end


/**

 *  uiview 设置frame

 */


@interface UIView (Layout)



@property (assign,nonatomic)CGFloat    x;

@property (assign,nonatomic)CGFloat    y;

@property (assign,nonatomic)CGPoint    origin;


@property (assign,nonatomic)CGFloat    centerX;

@property (assign,nonatomic)CGFloat    centerY;


@property (assign,nonatomic)CGFloat    width;

@property (assign,nonatomic)CGFloat    height;

@property (assign,nonatomic)CGSize     size;



@end



           .m 文件

#import "NSArray+log.h"

@implementation NSArray (log)

- (NSString *)descriptionWithLocale:(id)locale{
    NSMutableString * string = [[NSMutableString alloc]init];
    [string appendString:@"[\n"];
    for (int i = 0; i < self.count; i++) {
        [string appendFormat:@"\t%d -- %@,\n",i,self[i]];
    }
    [string stringByAppendingString:@"]\n"];
    return string;
}


@end



@implementation NSDictionary (Log)

- (NSString *)descriptionWithLocale:(id)locale
{
    NSMutableString *strM = [NSMutableString stringWithString:@"{\n"];
    
    [self enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
        [strM appendFormat:@"\t%@ = %@;\n", key, obj];
    }];
    
    [strM appendString:@"}\n"];
    
    return strM;
}

@end


/**

 *  uiview  frame 设置

 */



@implementation UIView (Layout)



@dynamic width;

@dynamic height;


@dynamic size;


@dynamic x;

@dynamic y;






- (CGFloat)x

{

    returnself.frame.origin.x;

}


- (void)setX:(CGFloat)value

{

    CGRect frame =self.frame;

    frame.origin.x = value;

    self.frame = frame;

}


- (CGFloat)y

{

    returnself.frame.origin.y;

}


- (void)setY:(CGFloat)value

{

    CGRect frame =self.frame;

    frame.origin.y = value;

    self.frame = frame;

}


- (CGPoint)origin

{

    returnself.frame.origin;

}


- (void)setOrigin:(CGPoint)origin

{

    CGRect frame =self.frame;

    frame.origin = origin;

    self.frame = frame;

}


- (CGFloat)centerX

{

    returnself.center.x;

}


- (void)setCenterX:(CGFloat)centerX

{

    CGPoint center =self.center;

    center.x = centerX;

    self.center = center;

}


- (CGFloat)centerY

{

    returnself.center.y;

}


- (void)setCenterY:(CGFloat)centerY

{

    CGPoint center =self.center;

    center.y = centerY;

    self.center = center;

}


- (CGFloat)width

{

    returnself.frame.size.width;

}


- (void)setWidth:(CGFloat)width

{

    CGRect frame =self.frame;

    frame.size.width = width;

    self.frame = frame;

}


- (CGFloat)height

{

    returnself.frame.size.height;

}


- (void)setHeight:(CGFloat)height

{

    CGRect frame =self.frame;

    frame.size.height = height;

    self.frame = frame;

}


- (CGSize)size

{

    returnself.frame.size;

}


- (void)setSize:(CGSize)size

{

    CGRect frame =self.frame;

    frame.size = size;

    self.frame = frame;

}


@end



0 0
原创粉丝点击