Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add centerHorizontallyInRect: helper

  • Loading branch information...
commit bff45eb939229f2531e6082738a4c2b979327f05 1 parent e16bb0e
@ettore authored
Showing with 20 additions and 6 deletions.
  1. +13 −6 categories/CLCGUIViewCategory.h
  2. +7 −0 categories/CLCGUIViewCategory.m
View
19 categories/CLCGUIViewCategory.h
@@ -28,22 +28,29 @@
@interface UIView (Candygirl)
-/** Moves the X position of the view to the center of its superview. */
+/*! Moves the X position of the view to the center of its superview. */
-(void)centerHorizontally;
-/**
+/*!
* Moves the X position of the view to the center of its superview, plus an
- * additional offset. */
+ * additional offset.
+ */
-(void)centerHorizontallyWithOffset:(CGFloat)offset;
-/** Moves the Y position of the view to the center of its superview. */
+/*! Moves the Y position of the view to the center of its superview. */
-(void)centerVertically;
-/**
+/*!
* Moves the Y position of the view to the center of its superview, plus an
- * additional offset. */
+ * additional offset.
+ */
-(void)centerVerticallyWithOffset:(CGFloat)offset;
+/*!
+ * Centers this view in the given rect.
+ */
+-(void)centerHorizontallyInRect:(CGRect)rect;
+
-(void)resizeHeightForText:(NSString*)txt font:(UIFont*)font;
-(UIView*)findFirstResponder;
View
7 categories/CLCGUIViewCategory.m
@@ -66,6 +66,13 @@ -(void)centerHorizontallyWithOffset:(CGFloat)offset
}
+-(void)centerHorizontallyInRect:(CGRect)rect
+{
+ CGFloat x = (rect.size.width - [self w])/2;
+ [self setX:(rect.origin.x + x)];
+}
+
+
-(void)resizeHeightForText:(NSString*)txt font:(UIFont*)font
{
CGSize sz;
Please sign in to comment.
Something went wrong with that request. Please try again.