Click Create UIView category, which is named Plextension (to correspond to the following)
View category. h file
#import <UIKit/UIKit.h>@interface UIView (plextension) @property (nonatomic, assign) CGFloat wl_width; @property (nonatomic, assign) CGFloat wl_height; @property (nonatomic, assign) CGFloat wl_x; @property ( Nonatomic, assign) CGFloat wl_y; @property (nonatomic, assign) CGFloat Wl_centerx; @property (nonatomic, assign) CGFloat WL _centery; @property (nonatomic, assign) CGFloat wl_right; @property (nonatomic, assign) cgfloat Wl_bottom; @end
. m file
#import "Uiview+plextension.h" @implementation UIView (wlextension)-(cgfloat) wl_width{return self.frame.size.width;} -(CGFloat) wl_height{return self.frame.size.height;} -(void) Setwl_width: (cgfloat) wl_width{cgrect frame = self.frame; Frame.size.width = Wl_width; Self.frame = frame;} -(void) Setwl_height: (cgfloat) wl_height{cgrect frame = self.frame; Frame.size.height = Wl_height; Self.frame = frame;} -(CGFloat) wl_x{return self.frame.origin.x;} -(void) setwl_x: (cgfloat) wl_x{cgrect frame = self.frame; frame.origin.x = wl_x; Self.frame = frame;} -(CGFloat) wl_y{return SELF.FRAME.ORIGIN.Y;} -(void) Setwl_y: (cgfloat) wl_y{cgrect frame = self.frame; FRAME.ORIGIN.Y = wl_y; Self.frame = frame;} -(CGFloat) wl_centerx{return self.center.x;} -(void) Setwl_centerx: (cgfloat) wl_centerx{Cgpoint Center = self.center; center.x = Wl_centerx; Self.center = center;} -(CGFloat) wl_centery{return self.center.y;} -(void) Setwl_centery: (cgfloat) WL_centery{Cgpoint Center = self.center; Center.y = Wl_centery; Self.center = center;} -(CGFloat) wl_right{//return self. Wl_x + self. Wl_width; Return Cgrectgetmaxx (self.frame);} -(CGFloat) wl_bottom{//return self. Wl_y + self. Wl_height; Return Cgrectgetmaxy (self.frame);} -(void) Setwl_right: (cgfloat) wl_right{self. wl_x = wl_right-self. Wl_width;} -(void) Setwl_bottom: (cgfloat) wl_bottom{self. Wl_y = wl_bottom-self. Wl_height;} @end
IOS Add View categories (more convenient to set the view location)