Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Change outerMargin and innerMargin to be margin and padding, respecti…

…vely. Also changed from a CGFloat to UIEdgeInsets for finer control
  • Loading branch information...
commit ca21ccd97aade7b068e95b9a0c0af7a9f85ef4e9 1 parent 5d64475
@coneybeare coneybeare authored
View
8 README.md
@@ -137,11 +137,11 @@ The best place to customize is in your UAModalPanel subclass.
**UAModalPanel Customizations**
````objective-c
-// Margin between edge of container frame and panel. Default = 20.0
-self.outerMargin = 30.0f;
+// Margin between edge of container frame and panel. Default = {20.0, 20.0, 20.0, 20.0}
+self.margin = UIEdgeInsetsMake(10.0, 20.0, 30.0, 20.0);
-// Margin between edge of panel and the content area. Default = 20.0
-self.innerMargin = 30.0f;
+// Padding between edge of panel and the content area. Default = {20.0, 20.0, 20.0, 20.0}
+self.padding = UIEdgeInsetsMake(10.0, 20.0, 30.0, 20.0);
// Border color of the panel. Default = [UIColor whiteColor]
self.borderColor = [UIColor blueColor];
View
BIN  UAModalPanel.xcodeproj/project.xcworkspace/xcuserdata/coneybeare.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown
View
8 UAModalPanel/Example Project/UAExampleModalPanel.m
@@ -30,11 +30,11 @@ - (id)initWithFrame:(CGRect)frame title:(NSString *)title {
// Funky time.
UADebugLog(@"Showing a randomized panel for modalPanel: %@", self);
- // Margin between edge of container frame and panel. Default = 20.0
- self.outerMargin = ((arc4random() % 4) + 1) * 20.0f;
+ // Margin between edge of container frame and panel. Default = {20.0, 20.0, 20.0, 20.0}
+ self.margin = UIEdgeInsetsMake(((arc4random() % 4) + 1) * 20.0f, ((arc4random() % 4) + 1) * 20.0f, ((arc4random() % 4) + 1) * 20.0f, ((arc4random() % 4) + 1) * 20.0f);
- // Margin between edge of panel and the content area. Default = 20.0
- self.innerMargin = ((arc4random() % 4) + 1) * 10.0f;
+ // Margin between edge of panel and the content area. Default = {20.0, 20.0, 20.0, 20.0}
+ self.padding = UIEdgeInsetsMake(((arc4random() % 4) + 1) * 20.0f, ((arc4random() % 4) + 1) * 20.0f, ((arc4random() % 4) + 1) * 20.0f, ((arc4random() % 4) + 1) * 20.0f);
// Border color of the panel. Default = [UIColor whiteColor]
self.borderColor = [UIColor colorWithRed:(arc4random() % 2) green:(arc4random() % 2) blue:(arc4random() % 2) alpha:1.0];
View
2  UAModalPanel/Example Project/UAViewController.m
@@ -24,7 +24,7 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface
- (IBAction)showModalPanel:(id)sender {
UAExampleModalPanel *modalPanel = [[[UAExampleModalPanel alloc] initWithFrame:self.view.bounds title:[(UIButton *)sender titleForState:UIControlStateNormal]] autorelease];
-
+
/////////////////////////////////
// Randomly use the blocks method, delgate methods, or neither of them
int blocksDelegateOrNone = arc4random() % 3;
View
33 UAModalPanel/Panel/Panels/UAModalPanel.h
@@ -33,20 +33,21 @@ typedef void (^UAModalDisplayPanelAnimationComplete)(BOOL finished);
@interface UAModalPanel : UIView {
NSObject<UAModalPanelDelegate> *delegate;
- UIView *contentContainer;
- UIView *roundedRect;
- UIButton *closeButton;
- UIView *contentView;
+ UIView *contentContainer;
+ UIView *roundedRect;
+ UIButton *closeButton;
+ UIView *contentView;
- CGPoint startEndPoint;
+ CGPoint startEndPoint;
- CGFloat outerMargin;
- CGFloat innerMargin;
- UIColor *borderColor;
- CGFloat borderWidth;
- CGFloat cornerRadius;
- UIColor *contentColor;
- BOOL shouldBounce;
+ UIEdgeInsets margin;
+ UIEdgeInsets padding;
+
+ UIColor *borderColor;
+ CGFloat borderWidth;
+ CGFloat cornerRadius;
+ UIColor *contentColor;
+ BOOL shouldBounce;
}
@@ -57,10 +58,10 @@ typedef void (^UAModalDisplayPanelAnimationComplete)(BOOL finished);
@property (nonatomic, retain) UIButton *closeButton;
@property (nonatomic, retain) UIView *contentView;
-// Margin between edge of container frame and panel. Default = 20.0
-@property (nonatomic, assign) CGFloat outerMargin;
-// Margin between edge of panel and the content area. Default = 20.0
-@property (nonatomic, assign) CGFloat innerMargin;
+// Margin between edge of container frame and panel. Default = {20.0, 20.0, 20.0, 20.0}
+@property (nonatomic, assign) UIEdgeInsets margin;
+// Padding between edge of panel and the content area. Default = {20.0, 20.0, 20.0, 20.0}
+@property (nonatomic, assign) UIEdgeInsets padding;
// Border color of the panel. Default = [UIColor whiteColor]
@property (nonatomic, retain) UIColor *borderColor;
// Border width of the panel. Default = 1.5f
View
25 UAModalPanel/Panel/Panels/UAModalPanel.m
@@ -22,7 +22,7 @@
@implementation UAModalPanel
@synthesize roundedRect, closeButton, delegate, contentView, contentContainer;
-@synthesize innerMargin, outerMargin, cornerRadius, borderWidth, borderColor, contentColor, shouldBounce;
+@synthesize margin, padding, cornerRadius, borderWidth, borderColor, contentColor, shouldBounce;
@synthesize onClosePressed;
@@ -35,8 +35,8 @@ - (id)initWithFrame:(CGRect)frame {
contentView = nil;
startEndPoint = CGPointZero;
- outerMargin = DEFAULT_MARGIN;
- innerMargin = DEFAULT_MARGIN;
+ margin = UIEdgeInsetsMake(DEFAULT_MARGIN, DEFAULT_MARGIN, DEFAULT_MARGIN, DEFAULT_MARGIN);
+ padding = UIEdgeInsetsMake(DEFAULT_MARGIN, DEFAULT_MARGIN, DEFAULT_MARGIN, DEFAULT_MARGIN);
cornerRadius = DEFAULT_CORNER_RADIUS;
borderWidth = DEFAULT_BORDER_WIDTH;
borderColor = [DEFAULT_BORDER_COLOR retain];
@@ -142,10 +142,10 @@ - (UIView *)contentView {
- (CGRect)roundedRectFrame {
- return CGRectMake(self.outerMargin + self.frame.origin.x,
- self.outerMargin + self.frame.origin.y,
- self.frame.size.width - 2*self.outerMargin,
- self.frame.size.height - 2*self.outerMargin);
+ return CGRectMake(self.margin.left + self.frame.origin.x,
+ self.margin.top + self.frame.origin.y,
+ self.frame.size.width - self.margin.left - self.margin.right,
+ self.frame.size.height - self.margin.top - self.margin.bottom);
}
- (CGRect)closeButtonFrame {
@@ -157,8 +157,11 @@ - (CGRect)closeButtonFrame {
}
- (CGRect)contentViewFrame {
- CGRect rect = CGRectInset([self roundedRectFrame], self.innerMargin, self.innerMargin);
- return rect;
+ CGRect roundedRectFrame = [self roundedRectFrame];
+ return CGRectMake(self.padding.left + roundedRectFrame.origin.x,
+ self.padding.top + roundedRectFrame.origin.y,
+ roundedRectFrame.size.width - self.padding.left - self.padding.right,
+ roundedRectFrame.size.height - self.padding.top - self.padding.bottom);
}
@@ -169,8 +172,8 @@ - (void)layoutSubviews {
self.closeButton.frame = [self closeButtonFrame];
self.contentView.frame = [self contentViewFrame];
-// UADebugLog(@"roundedRect frame: %@", NSStringFromCGRect(self.roundedRect.frame));
-// UADebugLog(@"contentView frame: %@", NSStringFromCGRect(self.contentView.frame));
+ UADebugLog(@"roundedRect frame: %@", NSStringFromCGRect(self.roundedRect.frame));
+ UADebugLog(@"contentView frame: %@", NSStringFromCGRect(self.contentView.frame));
}
- (void)closePressed:(id)sender {
View
8 UAModalPanel/Panel/Panels/UATitledModalPanel.m
@@ -67,10 +67,10 @@ - (CGRect)contentViewFrame {
CGRect titleBarFrame = [self titleBarFrame];
CGRect roundedRectFrame = [self roundedRectFrame];
CGFloat y = titleBarFrame.origin.y + titleBarFrame.size.height;
- CGRect rect = CGRectMake(self.outerMargin + self.innerMargin,
- self.outerMargin + self.innerMargin + y,
- roundedRectFrame.size.width - 2*self.innerMargin,
- roundedRectFrame.size.height - y - 2*self.innerMargin);
+ CGRect rect = CGRectMake(self.margin.left + self.padding.left,
+ self.margin.top + self.padding.top + y,
+ roundedRectFrame.size.width - self.padding.left - self.padding.right,
+ roundedRectFrame.size.height - y - self.padding.bottom - self.padding.bottom);
return rect;
}
Please sign in to comment.
Something went wrong with that request. Please try again.