From 2327a5030e18f4da9197a54f1d5c0bc8954e311a Mon Sep 17 00:00:00 2001 From: Ben Kreeger Date: Wed, 5 Jun 2013 09:46:07 -0500 Subject: [PATCH] Adding bounds properties to UIView category. --- BDKGeometry.podspec | 4 ++-- UIView+BDKGeometry.h | 6 +++++ UIView+BDKGeometry.m | 53 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 2 deletions(-) diff --git a/BDKGeometry.podspec b/BDKGeometry.podspec index fcaf17f..77d245c 100644 --- a/BDKGeometry.podspec +++ b/BDKGeometry.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'BDKGeometry' - s.version = '1.4.0' + s.version = '1.4.1' s.platform = :ios s.summary = "A set of helper functions I've been using in various XCode projects, abstracted for great good." s.homepage = 'http://github.com/kreeger/BDKGeometry' @@ -17,7 +17,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI LICENSE } s.author = { 'Ben Kreeger' => 'ben@kree.gr' } - s.source = { :git => 'https://github.com/kreeger/BDKGeometry.git', :tag => 'v1.4.0' } + s.source = { :git => 'https://github.com/kreeger/BDKGeometry.git', :tag => 'v1.4.1' } s.ios.deployment_target = '5.0' s.source_files = ['BDKGeometry.{h,m}', 'UIView+BDKGeometry.{h,m}'] s.requires_arc = true diff --git a/UIView+BDKGeometry.h b/UIView+BDKGeometry.h index 81e6bbc..89f8725 100644 --- a/UIView+BDKGeometry.h +++ b/UIView+BDKGeometry.h @@ -16,6 +16,12 @@ typedef enum { @property (nonatomic) CGSize frameSize; @property (nonatomic) CGFloat frameWidth; @property (nonatomic) CGFloat frameHeight; +@property (nonatomic) CGPoint boundsOrigin; +@property (nonatomic) CGFloat boundsXOrigin; +@property (nonatomic) CGFloat boundsYOrigin; +@property (nonatomic) CGSize boundsSize; +@property (nonatomic) CGFloat boundsWidth; +@property (nonatomic) CGFloat boundsHeight; /** Origin modification helper. * @param origin the origin to use. diff --git a/UIView+BDKGeometry.m b/UIView+BDKGeometry.m index 900269e..7fae7b2 100644 --- a/UIView+BDKGeometry.m +++ b/UIView+BDKGeometry.m @@ -4,6 +4,9 @@ @implementation UIView (BDKGeometry) @dynamic frameOrigin, frameXOrigin, frameYOrigin, frameSize, frameWidth, frameHeight; +@dynamic boundsOrigin, boundsXOrigin, boundsYOrigin, boundsSize, boundsWidth, boundsHeight; + +#pragma mark - Frame methods - (void)setFrameOrigin:(CGPoint)frameOrigin { self.frame = CGRectSetOrigin(self.frame, frameOrigin); @@ -53,6 +56,56 @@ - (CGFloat)frameHeight { return self.frame.size.height; } +#pragma mark - Bounds methods + +- (void)setBoundsOrigin:(CGPoint)boundsOrigin { + self.bounds = CGRectSetOrigin(self.bounds, boundsOrigin); +} + +- (CGPoint)boundsOrigin { + return self.bounds.origin; +} + +- (void)setBoundsXOrigin:(CGFloat)boundsXOrigin { + self.bounds = CGRectSetXOrigin(self.bounds, boundsXOrigin); +} + +- (CGFloat)boundsXOrigin { + return self.bounds.origin.x; +} + +- (void)setBoundsYOrigin:(CGFloat)boundsYOrigin { + self.bounds = CGRectSetYOrigin(self.bounds, boundsYOrigin); +} + +- (CGFloat)boundsYOrigin { + return self.bounds.origin.y; +} + +- (void)setBoundsSize:(CGSize)boundsSize { + self.bounds = CGRectSetSize(self.bounds, boundsSize); +} + +- (CGSize)boundsSize { + return self.bounds.size; +} + +- (void)setBoundsWidth:(CGFloat)boundsWidth { + self.bounds = CGRectSetWidth(self.bounds, boundsWidth); +} + +- (CGFloat)boundsWidth { + return self.bounds.size.width; +} + +- (void)setBoundsHeight:(CGFloat)boundsHeight { + self.bounds = CGRectSetHeight(self.bounds, boundsHeight); +} + +- (CGFloat)boundsHeight { + return self.bounds.size.height; +} + - (void)positionViewBelowView:(UIView *)view { [self positionViewBelowView:view padding:0]; }