Skip to content
Browse files

Add SSButton

  • Loading branch information...
1 parent 5c03813 commit 975861093dab6baf85916a164d8a708da0e1f7aa @soffes soffes committed Apr 14, 2012
Showing with 50 additions and 0 deletions.
  1. +18 −0 SSToolkit/SSButton.h
  2. +31 −0 SSToolkit/SSButton.m
  3. +1 −0 SSToolkit/SSToolkit.h
View
18 SSToolkit/SSButton.h
@@ -0,0 +1,18 @@
+//
+// SSButton.h
+// SSToolkit
+//
+// Created by Sam Soffes on 4/14/12.
+// Copyright (c) 2012 Sam Soffes. All rights reserved.
+//
+
+typedef enum {
+ SSButtonImagePositionLeft,
+ SSButtonImagePositionRight
+} SSButtonImagePosition;
+
+@interface SSButton : UIButton
+
+@property (nonatomic, assign) SSButtonImagePosition imagePosition;
+
+@end
View
31 SSToolkit/SSButton.m
@@ -0,0 +1,31 @@
+//
+// SSButton.m
+// SSToolkit
+//
+// Created by Sam Soffes on 4/14/12.
+// Copyright (c) 2012 Sam Soffes. All rights reserved.
+//
+
+#import "SSButton.h"
+
+@implementation SSButton
+
+@synthesize imagePosition = _imagePosition;
+
+- (void)layoutSubviews {
+ [super layoutSubviews];
+ if (_imagePosition == SSButtonImagePositionLeft) {
+ return;
+ }
+
+ CGRect imageFrame = self.imageView.frame;
+ CGRect labelFrame = self.titleLabel.frame;
+
+ labelFrame.origin.x = imageFrame.origin.x - self.imageEdgeInsets.left + self.imageEdgeInsets.right;
+ imageFrame.origin.x += labelFrame.size.width;
+
+ self.imageView.frame = imageFrame;
+ self.titleLabel.frame = labelFrame;
+}
+
+@end
View
1 SSToolkit/SSToolkit.h
@@ -28,6 +28,7 @@
// Controls
#import <SSToolkit/SSAddressBarTextField.h>
+#import <SSToolkit/SSButton.h>
#import <SSToolkit/SSTextField.h>
#import <SSToolkit/SSTextView.h>
#import <SSToolkit/SSRatingPicker.h>

0 comments on commit 9758610

Please sign in to comment.
Something went wrong with that request. Please try again.