iOS-UIView一些座標和位置方法封裝,ios-uiview封裝

來源:互聯網
上載者:User

iOS-UIView一些座標和位置方法封裝,ios-uiview封裝

 

建立基於UIView擴充類 UIView+wkjFrame,直接引用即可

UIView+wkjFrame.h

- (CGPoint)origin;- (void)setOrigin:(CGPoint) point;- (CGSize)size;- (void)setSize:(CGSize) size;- (CGFloat)x;- (void)setX:(CGFloat)x;- (CGFloat)y;- (void)setY:(CGFloat)y;- (CGFloat)height;- (void)setHeight:(CGFloat)height;- (CGFloat)width;- (void)setWidth:(CGFloat)width;- (CGFloat)tail;- (void)setTail:(CGFloat)tail;- (CGFloat)bottom;- (void)setBottom:(CGFloat)bottom;- (CGFloat)right;- (void)setRight:(CGFloat)right;

UIView+wkjFrame.m

#import "UIView+wkjFrame.h"@implementation UIView (wkjFrame)- (CGPoint) origin {    return self.frame.origin;}- (void) setOrigin:(CGPoint) point {    self.frame = CGRectMake(point.x, point.y, self.frame.size.width, self.frame.size.height);}- (CGSize) size {    return self.frame.size;}- (void) setSize:(CGSize) size {    self.frame = CGRectMake(self.x, self.y, size.width, size.height);}- (CGFloat) x {    return self.frame.origin.x;}- (void) setX:(CGFloat)x {    self.frame = CGRectMake(x, self.y, self.width, self.height);}- (CGFloat) y {    return self.frame.origin.y;}- (void) setY:(CGFloat)y {    self.frame = CGRectMake(self.x, y, self.width, self.height);}- (CGFloat) height {    return self.frame.size.height;}- (void)setHeight:(CGFloat)height {    self.frame = CGRectMake(self.x, self.y, self.width, height);}- (CGFloat)width {    return self.frame.size.width;}- (void)setWidth:(CGFloat)width {    self.frame = CGRectMake(self.x, self.y, width, self.height);}- (CGFloat)tail {    return self.y + self.height;}- (void)setTail:(CGFloat)tail {    self.frame = CGRectMake(self.x, tail - self.height, self.width, self.height);}- (CGFloat)bottom {    return self.tail;}- (void)setBottom:(CGFloat)bottom {    [self setTail:bottom];}- (CGFloat)right {    return self.x + self.width;}- (void)setRight:(CGFloat)right {    self.frame = CGRectMake(right - self.width, self.y, self.width, self.height);}@end

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.