美文网首页
UIView+Extension

UIView+Extension

作者: 特喵了个咪的猫 | 来源:发表于2017-01-10 12:07 被阅读0次

//x坐标属性

@property (nonatomic,assign)CGFloat x;

//y坐标

@property (nonatomic,assign)CGFloat y;

//宽度

@property (nonatomic,assign)CGFloat width;

//高度

@property (nonatomic,assign)CGFloat height;

//大小

@property (nonatomic,assign)CGSize size;

//位置

@property (nonatomic,assign)CGPoint origin;

//中心点x

@property (nonatomic,assign)CGFloat centerX;

//中心点y

@property (nonatomic,assign)CGFloat centerY;


//x属性的get,set

-(void)setX:(CGFloat)x

{

CGRect frame=self.frame;

frame.origin.x=x;

self.frame=frame;

}

-(CGFloat)x

{

return self.frame.origin.x;

}

//centerX属性的get,set

-(void)setCenterX:(CGFloat)centerX

{

CGPoint center=self.center;

center.x=centerX;

self.center=center;

}

-(CGFloat)centerX

{

return self.center.x;

}

//centerY属性的get,set

-(void)setCenterY:(CGFloat)centerY

{

CGPoint center=self.center;

center.y=centerY;

self.center=center;

}

-(CGFloat)centerY

{

return self.center.y;

}

//y属性的get,set

-(void)setY:(CGFloat)y

{

CGRect frame=self.frame;

frame.origin.y=y;

self.frame=frame;

}

-(CGFloat)y

{

return self.frame.origin.y;

}

//width属性的get,set

-(void)setWidth:(CGFloat)width

{

CGRect frame=self.frame;

frame.size.width=width;

self.frame=frame;

}

-(CGFloat)width

{

return self.frame.size.width;

}

//height属性的get,set

-(void)setHeight:(CGFloat)height

{

CGRect frame=self.frame;

frame.size.height=height;

self.frame=frame;

}

-(CGFloat)height

{

return self.frame.size.height;

}

//size属性的get,set

-(void)setSize:(CGSize)size

{

CGRect frame=self.frame;

frame.size.width=size.width;

frame.size.height=size.height;

self.frame=frame;

}

-(CGSize)size

{

return self.frame.size;

}

//origin属性的get,set,用于设置坐标

-(void)setOrigin:(CGPoint)origin

{

CGRect frame=self.frame;

frame.origin.x=origin.x;

frame.origin.y=origin.y;

self.frame=frame;

}

-(CGPoint)origin

{

return self.frame.origin;

}

相关文章

网友评论

      本文标题:UIView+Extension

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