// // FrameAccessor.h // FrameAccessor // // Created by Alex Denisov on 18.03.12. // Copyright (c) 2013 okolodev.org. All rights reserved. // #if (TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE) #import <UIKit/UIKit.h> #define View UIView #else #import <Foundation/Foundation.h> #define View NSView #endif @interface UIView (FrameAccessor) - (CGPoint)origin; - (void)setOrigin:(CGPoint)newOrigin; - (CGSize)size; - (void)setSize:(CGSize)newSize; - (CGFloat)x; - (void)setX:(CGFloat)newX; - (CGFloat)y; - (void)setY:(CGFloat)newY; - (CGFloat)height; - (void)setHeight:(CGFloat)newHeight; - (CGFloat)width; - (void)setWidth:(CGFloat)newWidth; - (CGFloat)bottom; - (CGFloat)right; @end
// FrameAccessor.m // FrameAccessor // // Created by Alex Denisov on 18.03.12. // Copyright (c) 2013 okolodev.org. All rights reserved. // #import "FrameAccessor.h" @implementation UIView (FrameAccessor) - (CGPoint)origin { return self.frame.origin; } - (void)setOrigin:(CGPoint)newOrigin { CGRect newFrame = self.frame; newFrame.origin = newOrigin; self.frame = newFrame; } - (CGSize)size { return self.frame.size; } - (void)setSize:(CGSize)newSize { CGRect newFrame = self.frame; newFrame.size = newSize; self.frame = newFrame; } - (CGFloat)x { return self.frame.origin.x; } - (void)setX:(CGFloat)newX { CGRect newFrame = self.frame; newFrame.origin.x = newX; self.frame = newFrame; } - (CGFloat)y { return self.frame.origin.y; } - (void)setY:(CGFloat)newY { CGRect newFrame = self.frame; newFrame.origin.y = newY; self.frame = newFrame; } - (CGFloat)height { return self.frame.size.height; } - (void)setHeight:(CGFloat)newHeight { CGRect newFrame = self.frame; newFrame.size.height = newHeight; self.frame = newFrame; } - (CGFloat)width { return self.frame.size.width; } - (void)setWidth:(CGFloat)newWidth { CGRect newFrame = self.frame; newFrame.size.width = newWidth; self.frame = newFrame; } - (CGFloat)bottom { return self.frame.origin.y + self.frame.size.height; } - (CGFloat)right { return self.frame.origin.x + self.frame.size.width; } @end