Classification of UIView--ios

Source: Internet
Author: User

#import <UIKit/UIKit.h>

@interface UIView (pjxextension)

@property (assign,nonatomic) CGFloat x; X-coordinate

@property (assign,nonatomic) cgfloat y; Y-coordinate

@property (assign,nonatomic) cgfloat width; Width

@property (assign,nonatomic) cgfloat height; Height

@property (assign,nonatomic) cgfloat CenterX; Center point x Value

@property (assign,nonatomic) cgfloat centery; Center Point Y Value

@end

#import "Uiview+pjxextension.h"

@implementation UIView (pjxextension)

X

-(void) SetX: (cgfloat) x{

CGRect frame = self.frame;

frame.origin.x = x;

Self.frame = frame;

}

-(CGFloat) x{

return self.frame.origin.x;

}

Y

-(void) Sety: (cgfloat) y{

CGRect frame = self.frame;

FRAME.ORIGIN.Y = y;

Self.frame = frame;

}

-(CGFloat) y{

return SELF.FRAME.ORIGIN.Y;

}

Width

-(void) SetWidth: (cgfloat) width{

CGRect frame = self.frame;

Frame.size.width = width;

Self.frame = frame;

}

-(CGFloat) width{

return self.frame.size.width;

}

Height

-(void) SetHeight: (cgfloat) height{

CGRect frame = self.frame;

Frame.size.height = height;

Self.frame = frame;

}

-(CGFloat) height{

return self.frame.size.height;

}

CenterX

-(void) Setcenterx: (cgfloat) centerx{

CGRect frame = self.frame;

frame.origin.x = centerx-frame.size.width/2.0;

Self.frame = frame;

}

-(CGFloat) centerx{

Return Cgrectgetmidx (Self.frame);

}

CenterY

-(void) Setcentery: (cgfloat) centery{

CGRect frame = self.frame;

FRAME.ORIGIN.Y = centery-frame.size.height/2.0;

Self.frame = frame;

}

-(CGFloat) centery{

Return Cgrectgetmidy (Self.frame);

}

/*

Center X

-(CGFloat) CenterX

{

return self.center.x;

}

-(void) Setcenterx: (cgfloat) CenterX

{

Cgpoint Center = self.center;

center.x = CenterX;

Self.center = center;

}

Center Point Y

-(CGFloat) centery

{

return self.center.y;

}

-(void) Setcentery: (cgfloat) CenterY

{

Cgpoint Center = self.center;

Center.y = CenterY;

Self.center = center;

}

*/

@end

Classification of UIView--ios

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.