建一个UIView类目
.h文件
@property(nonatomic,assign)CGFloat x;
@property(nonatomic,assign)CGFloat y;
@property(nonatomic,assign)CGFloat centerX;
@property(nonatomic,assign)CGFloat centerY;
@property(nonatomic,assign)CGFloat Height;
@property(nonatomic,assign)CGFloat Width;
@property(nonatomic,assign)CGSize Size;
@property(nonatomic,assign)CGPoint Oringe;
.m 文件
-(void)setX:(CGFloat)x{
CGRect frame =self.frame;
frame.origin.x =x;
self.frame =frame;
}
-(void)setY:(CGFloat)y{
CGRect frame =self.frame;
frame.origin.y =y;
self.frame =frame;
}
- (void)setCenterX:(CGFloat)centerX
{
CGPoint center = self.center;
center.x = centerX;
self.center = center;
}
-(void)setCenterY:(CGFloat)centerY{
CGPoint center =self.center;
center.y =centerY;
self.center =center;
}
- (CGFloat)centerX
{
return self.center.x;
}
-(CGFloat)centerY{
return self.center.y;
}
-(void)setHeight:(CGFloat)Height{
CGRect frame =self.frame;
frame.size.height = Height;
self.frame =frame;
}
-(void)setWidth:(CGFloat)Width{
CGRect frame =self.frame;
frame.size.width =Width;
self.frame =frame;
}
-(void)setSize:(CGSize)Size{
CGRect frame =self.frame;
frame.size =Size;
self.frame =frame;
}
-(void)setPoint:(CGPoint)Oringe{
CGRect frame = self.frame;
frame.origin =Oringe;
self.frame =frame;
}
-(void)setOringe:(CGPoint)Oringe{
CGRect frame =self.frame;
frame.origin =Oringe;
self.frame=frame;
}
-(CGFloat)y{
return self.frame.origin.y;
}
-(CGFloat)x{
return self.frame.origin.x;
}
-(CGFloat)Height{
return self.frame.size.height;
}
-(CGFloat)Width{
return self.frame.size.width;
}
-(CGSize)Size{
return self.frame.size;
}
-(CGPoint)Oringe{
return self.frame.origin;
}