iOS settings frame when you often have to take out the set--and finally, and then assign value back, very troublesome, today to recommend a very fast method

Source: Internet
Author: User

Everyone can go to my githup download https://github.com/simplyou/YJ-UIIView-/tree/master

When setting the size of the pro have no feeling very painful ah, here provides a set of classification, directly into the project, in the PCH contains the header file can solve your egg pain problem;

/***********************. h file ********************************

Uiview+yj.h

Created by lightning on 14-6-8.

Copyright (c) 2014 Wen Yanjun. All rights reserved.

This classification provides a quick way to solve the problem of setting a wide height in OC

#import <UIKit/UIKit.h>

@interface UIView (YJ)

@property (nonatomic, assign) CGFloat x;

@property (nonatomic, assign) CGFloat y;

@property (nonatomic, assign) CGFloat CenterX;

@property (nonatomic, assign) CGFloat centery;

@property (nonatomic, assign) cgfloat width;

@property (nonatomic, assign) cgfloat height;

@property (nonatomic, assign) cgsize size;

@end

/***************************** Ornate Split Line **********************

. m file **********************************

Uiview+yj.h

Created by lightning on 14-6-8.

Copyright (c) 2014 Wen Yanjun. All rights reserved.

This classification provides a quick way to solve the problem of setting a wide height in OC

#import "Uiview+yj.h"

@implementation UIView (YJ)

-(void) SetSize: (cgsize) size

{

CGRect frame = self.frame;

frame.size = size;

Self.frame = frame;

}

-(cgsize) size

{

return self.frame.size;

}

-(void) SetX: (cgfloat) x

{

CGRect frame = self.frame;

frame.origin.x = x;

Self.frame = frame;

}

-(CGFloat) x

{

return self.frame.origin.x;

}

-(void) Sety: (cgfloat) y

{

CGRect frame = self.frame;

FRAME.ORIGIN.Y = y;

Self.frame = frame;

}

-(CGFloat) y

{

return SELF.FRAME.ORIGIN.Y;

}

-(void) Setcenterx: (cgfloat) CenterX

{

Cgpoint Center = self.center;

center.x = CenterX;

Self.center = center;

}

-(CGFloat) CenterX

{

return self.center.x;

}

-(void) Setcentery: (cgfloat) CenterY

{

Cgpoint Center = self.center;

Center.y = CenterY;

Self.center = center;

}

-(CGFloat) centery

{

return self.center.y;

}

-(void) SetWidth: (cgfloat) width

{

CGRect frame = self.frame;

Frame.size.width = width;

Self.frame = frame;

}

-(CGFloat) width

{

return self.frame.size.width;

}

-(void) SetHeight: (cgfloat) height

{

CGRect frame = self.frame;

Frame.size.height = height;

Self.frame = frame;

}

-(cgfloat) Height

{

return self.frame.size.height;

}

@end

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.