diff --git a/UAModalPanel.xcodeproj/project.pbxproj b/UAModalPanel.xcodeproj/project.pbxproj old mode 100644 new mode 100755 index 4946ce2..ba6093f --- a/UAModalPanel.xcodeproj/project.pbxproj +++ b/UAModalPanel.xcodeproj/project.pbxproj @@ -28,11 +28,9 @@ E65CAB3514CFB98C004F3776 /* UAViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E65CAB2414CFB98C004F3776 /* UAViewController.m */; }; E65CAB3614CFB98C004F3776 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = E65CAB2614CFB98C004F3776 /* main.m */; }; E65CAB3A14CFB98C004F3776 /* UAAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = E65CAB2F14CFB98C004F3776 /* UAAppDelegate.m */; }; - E65CAB3B14CFB98C004F3776 /* UAModalPanel-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = E65CAB3014CFB98C004F3776 /* UAModalPanel-Info.plist */; }; E65CAB3C14CFB98C004F3776 /* UrbanApps.png in Resources */ = {isa = PBXBuildFile; fileRef = E65CAB3214CFB98C004F3776 /* UrbanApps.png */; }; E65CAB4314CFB9A8004F3776 /* UAViewController_iPhone.xib in Resources */ = {isa = PBXBuildFile; fileRef = E65CAB3D14CFB9A8004F3776 /* UAViewController_iPhone.xib */; }; E65CAB4414CFB9A8004F3776 /* UAViewController_iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = E65CAB3F14CFB9A8004F3776 /* UAViewController_iPad.xib */; }; - E65CAB4514CFB9A8004F3776 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = E65CAB4114CFB9A8004F3776 /* InfoPlist.strings */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -214,8 +212,8 @@ children = ( E65CAB2E14CFB98C004F3776 /* UAAppDelegate.h */, E65CAB2F14CFB98C004F3776 /* UAAppDelegate.m */, - E65CAB2414CFB98C004F3776 /* UAViewController.m */, E65CAB2514CFB98C004F3776 /* UAViewController.h */, + E65CAB2414CFB98C004F3776 /* UAViewController.m */, E65CAB2114CFB98C004F3776 /* UAExampleModalPanel.m */, E65CAB2214CFB98C004F3776 /* UAExampleModalPanel.h */, E65CAB4614CFB9C1004F3776 /* Images */, @@ -282,11 +280,9 @@ E65CAB1A14CFB930004F3776 /* close.png in Resources */, E65CAB1B14CFB930004F3776 /* close@2x.png in Resources */, E65CAB3414CFB98C004F3776 /* UAExampleView.xib in Resources */, - E65CAB3B14CFB98C004F3776 /* UAModalPanel-Info.plist in Resources */, E65CAB3C14CFB98C004F3776 /* UrbanApps.png in Resources */, E65CAB4314CFB9A8004F3776 /* UAViewController_iPhone.xib in Resources */, E65CAB4414CFB9A8004F3776 /* UAViewController_iPad.xib in Resources */, - E65CAB4514CFB9A8004F3776 /* InfoPlist.strings in Resources */, E659BE00158D633F0031B337 /* modalButton.png in Resources */, E659BE01158D633F0031B337 /* modalButton@2x.png in Resources */, E659BE11158D6AFF0031B337 /* modalButton-selected.png in Resources */, @@ -392,6 +388,7 @@ E64F522314BA98FA009CB18D /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ENABLE_OBJC_ARC = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "UAModalPanel/Example Project/UAModalPanel-Prefix.pch"; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -411,6 +408,7 @@ E64F522414BA98FA009CB18D /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ENABLE_OBJC_ARC = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "UAModalPanel/Example Project/UAModalPanel-Prefix.pch"; GCC_VERSION = ""; diff --git a/UAModalPanel/Example Project/UAAppDelegate.m b/UAModalPanel/Example Project/UAAppDelegate.m old mode 100644 new mode 100755 index 7724f14..4a8b092 --- a/UAModalPanel/Example Project/UAAppDelegate.m +++ b/UAModalPanel/Example Project/UAAppDelegate.m @@ -15,21 +15,15 @@ @implementation UAAppDelegate @synthesize window = _window; @synthesize viewController = _viewController; -- (void)dealloc -{ - [_window release]; - [_viewController release]; - [super dealloc]; -} - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; + self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { - self.viewController = [[[UAViewController alloc] initWithNibName:@"UAViewController_iPhone" bundle:nil] autorelease]; + self.viewController = [[UAViewController alloc] initWithNibName:@"UAViewController_iPhone" bundle:nil]; } else { - self.viewController = [[[UAViewController alloc] initWithNibName:@"UAViewController_iPad" bundle:nil] autorelease]; + self.viewController = [[UAViewController alloc] initWithNibName:@"UAViewController_iPad" bundle:nil]; } self.window.rootViewController = self.viewController; [self.window makeKeyAndVisible]; diff --git a/UAModalPanel/Example Project/UAExampleModalPanel.h b/UAModalPanel/Example Project/UAExampleModalPanel.h old mode 100644 new mode 100755 index 839402b..515b45a --- a/UAModalPanel/Example Project/UAExampleModalPanel.h +++ b/UAModalPanel/Example Project/UAExampleModalPanel.h @@ -13,7 +13,7 @@ IBOutlet UIView *viewLoadedFromXib; } -@property (nonatomic, retain) IBOutlet UIView *viewLoadedFromXib; +@property (nonatomic, strong) IBOutlet UIView *viewLoadedFromXib; - (id)initWithFrame:(CGRect)frame title:(NSString *)title; - (IBAction)buttonPressed:(id)sender; diff --git a/UAModalPanel/Example Project/UAExampleModalPanel.m b/UAModalPanel/Example Project/UAExampleModalPanel.m old mode 100644 new mode 100755 index 25d9ad3..b2f0ed1 --- a/UAModalPanel/Example Project/UAExampleModalPanel.m +++ b/UAModalPanel/Example Project/UAExampleModalPanel.m @@ -81,13 +81,13 @@ - (id)initWithFrame:(CGRect)frame title:(NSString *)title { ////////////////////////////////////// // SETUP RANDOM CONTENT ////////////////////////////////////// - UIWebView *wv = [[[UIWebView alloc] initWithFrame:CGRectZero] autorelease]; + UIWebView *wv = [[UIWebView alloc] initWithFrame:CGRectZero]; [wv loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://urbanapps.com/product_list"]]]; - UITableView *tv = [[[UITableView alloc] initWithFrame:CGRectZero] autorelease]; + UITableView *tv = [[UITableView alloc] initWithFrame:CGRectZero]; [tv setDataSource:self]; - UIImageView *iv = [[[UIImageView alloc] initWithFrame:CGRectZero] autorelease]; + UIImageView *iv = [[UIImageView alloc] initWithFrame:CGRectZero]; [iv setImage:[UIImage imageNamed:@"UrbanApps.png"]]; [iv setContentMode:UIViewContentModeScaleAspectFit]; @@ -96,18 +96,13 @@ - (id)initWithFrame:(CGRect)frame title:(NSString *)title { NSArray *contentArray = [NSArray arrayWithObjects:wv, tv, iv, viewLoadedFromXib, nil]; int i = arc4random() % [contentArray count]; - v = [[contentArray objectAtIndex:i] retain]; + v = [contentArray objectAtIndex:i]; [self.contentView addSubview:v]; } return self; } -- (void)dealloc { - [v release]; - [viewLoadedFromXib release]; - [super dealloc]; -} - (void)layoutSubviews { [super layoutSubviews]; @@ -125,7 +120,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N NSString *cellIdentifier = @"UAModalPanelCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; if (cell == nil) { - cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier] autorelease]; + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; } [cell.textLabel setText:[NSString stringWithFormat:@"Row %d", indexPath.row]]; @@ -138,8 +133,8 @@ - (IBAction)buttonPressed:(id)sender { // The button was pressed. Lets do something with it. // Maybe the delegate wants something to do with it... - if ([delegate respondsToSelector:@selector(superAwesomeButtonPressed:)]) { - [delegate performSelector:@selector(superAwesomeButtonPressed:) withObject:sender]; + if ([self.delegate respondsToSelector:@selector(superAwesomeButtonPressed:)]) { + [self.delegate performSelector:@selector(superAwesomeButtonPressed:) withObject:sender]; // Or perhaps someone is listening for notifications } else { diff --git a/UAModalPanel/Example Project/UAViewController.m b/UAModalPanel/Example Project/UAViewController.m old mode 100644 new mode 100755 index 62e6ca2..fbbc251 --- a/UAModalPanel/Example Project/UAViewController.m +++ b/UAModalPanel/Example Project/UAViewController.m @@ -23,7 +23,7 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface - (IBAction)showModalPanel:(id)sender { - UAExampleModalPanel *modalPanel = [[[UAExampleModalPanel alloc] initWithFrame:self.view.bounds title:[(UIButton *)sender titleForState:UIControlStateNormal]] autorelease]; + UAExampleModalPanel *modalPanel = [[UAExampleModalPanel alloc] initWithFrame:self.view.bounds title:[(UIButton *)sender titleForState:UIControlStateNormal]]; ///////////////////////////////// // Randomly use the blocks method, delgate methods, or neither of them @@ -37,18 +37,19 @@ - (IBAction)showModalPanel:(id)sender { // The block is responsible for closing the panel, // either with -[UAModalPanel hide] or -[UAModalPanel hideWithOnComplete:] // Panel is a reference to the modalPanel + __weak UAExampleModalPanel *weakModalPanel = modalPanel; modalPanel.onClosePressed = ^(UAModalPanel* panel) { // [panel hide]; [panel hideWithOnComplete:^(BOOL finished) { [panel removeFromSuperview]; }]; - UADebugLog(@"onClosePressed block called from panel: %@", modalPanel); + UADebugLog(@"onClosePressed block called from panel: %@", weakModalPanel); }; /////////////////////////////////////////// // Panel is a reference to the modalPanel modalPanel.onActionPressed = ^(UAModalPanel* panel) { - UADebugLog(@"onActionPressed block called from panel: %@", modalPanel); + UADebugLog(@"onActionPressed block called from panel: %@", weakModalPanel); }; UADebugLog(@"UAModalView will display using blocks: %@", modalPanel); diff --git a/UAModalPanel/Panel/Categories/UIView+JMNoise.m b/UAModalPanel/Panel/Categories/UIView+JMNoise.m old mode 100644 new mode 100755 index ccb01c3..5aa7a19 --- a/UAModalPanel/Panel/Categories/UIView+JMNoise.m +++ b/UAModalPanel/Panel/Categories/UIView+JMNoise.m @@ -99,7 +99,7 @@ - (void)applyNoise; - (void)applyNoiseWithOpacity:(CGFloat)opacity atLayerIndex:(NSUInteger) layerIndex; { - NoiseLayer * noiseLayer = [[[NoiseLayer alloc] init] autorelease]; + NoiseLayer * noiseLayer = [[NoiseLayer alloc] init]; [noiseLayer setFrame:self.bounds]; noiseLayer.masksToBounds = YES; noiseLayer.opacity = opacity; diff --git a/UAModalPanel/Panel/Panels/UAModalPanel.h b/UAModalPanel/Panel/Panels/UAModalPanel.h index c80d430..62b6303 100755 --- a/UAModalPanel/Panel/Panels/UAModalPanel.h +++ b/UAModalPanel/Panel/Panels/UAModalPanel.h @@ -31,53 +31,35 @@ typedef void (^UAModalDisplayPanelEvent)(UAModalPanel* panel); typedef void (^UAModalDisplayPanelAnimationComplete)(BOOL finished); -@interface UAModalPanel : UIView { - NSObject *delegate; - - UIView *contentContainer; - UIView *roundedRect; - UIButton *closeButton; - UIButton *actionButton; - UIView *contentView; - - CGPoint startEndPoint; - - UIEdgeInsets margin; - UIEdgeInsets padding; - - UIColor *borderColor; - CGFloat borderWidth; - CGFloat cornerRadius; - UIColor *contentColor; - BOOL shouldBounce; - -} +@interface UAModalPanel : UIView -@property (nonatomic, assign) NSObject *delegate; +@property (nonatomic, unsafe_unretained) NSObject *delegate; -@property (nonatomic, retain) UIView *contentContainer; -@property (nonatomic, retain) UIView *roundedRect; -@property (nonatomic, retain) UIButton *closeButton; -@property (nonatomic, retain) UIButton *actionButton; -@property (nonatomic, retain) UIView *contentView; +@property (nonatomic, strong) UIView *contentContainer; +@property (nonatomic, strong) UIView *roundedRect; +@property (nonatomic, strong) UIButton *closeButton; +@property (nonatomic, strong) UIButton *actionButton; +@property (nonatomic, strong) UIView *contentView; // Margin between edge of container frame and panel. Default = {20.0, 20.0, 20.0, 20.0} -@property (nonatomic, assign) UIEdgeInsets margin; +@property (nonatomic) 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; +@property (nonatomic) UIEdgeInsets padding; // Border color of the panel. Default = [UIColor whiteColor] -@property (nonatomic, retain) UIColor *borderColor; +@property (nonatomic, strong) UIColor *borderColor; // Border width of the panel. Default = 1.5f -@property (nonatomic, assign) CGFloat borderWidth; +@property (nonatomic) CGFloat borderWidth; // Corner radius of the panel. Default = 4.0f -@property (nonatomic, assign) CGFloat cornerRadius; +@property (nonatomic) CGFloat cornerRadius; // Color of the panel itself. Default = [UIColor colorWithWhite:0.0 alpha:0.8] -@property (nonatomic, retain) UIColor *contentColor; +@property (nonatomic, strong) UIColor *contentColor; // Shows the bounce animation. Default = YES -@property (nonatomic, assign) BOOL shouldBounce; +@property (nonatomic) BOOL shouldBounce; -@property (readwrite, copy) UAModalDisplayPanelEvent onClosePressed; -@property (readwrite, copy) UAModalDisplayPanelEvent onActionPressed; +@property (nonatomic) CGPoint startEndPoint; + +@property (readwrite, copy) UAModalDisplayPanelEvent onClosePressed; +@property (readwrite, copy) UAModalDisplayPanelEvent onActionPressed; - (void)show; - (void)showFromPoint:(CGPoint)point; diff --git a/UAModalPanel/Panel/Panels/UAModalPanel.m b/UAModalPanel/Panel/Panels/UAModalPanel.m index a787a61..e0f1921 100755 --- a/UAModalPanel/Panel/Panels/UAModalPanel.m +++ b/UAModalPanel/Panel/Panels/UAModalPanel.m @@ -21,41 +21,35 @@ @implementation UAModalPanel -@synthesize roundedRect, closeButton, actionButton, delegate, contentView, contentContainer; -@synthesize margin, padding, cornerRadius, borderWidth, borderColor, contentColor, shouldBounce; -@synthesize onClosePressed, onActionPressed; - - - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self != nil) { - delegate = nil; - roundedRect = nil; - closeButton = nil; - actionButton = nil; - contentView = nil; - startEndPoint = CGPointZero; + _delegate = nil; + _roundedRect = nil; + _closeButton = nil; + _actionButton = nil; + _contentView = nil; + _startEndPoint = CGPointZero; - 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]; - contentColor = [DEFAULT_BACKGROUND_COLOR retain]; - shouldBounce = DEFAULT_BOUNCE; + _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; + _contentColor = DEFAULT_BACKGROUND_COLOR; + _shouldBounce = DEFAULT_BOUNCE; self.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight; self.autoresizesSubviews = YES; - self.contentContainer = [[[UIView alloc] initWithFrame:self.bounds] autorelease]; - self.contentContainer.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight; - self.contentContainer.autoresizesSubviews = YES; - [self addSubview:self.contentContainer]; + _contentContainer = [[UIView alloc] initWithFrame:self.bounds]; + _contentContainer.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight; + _contentContainer.autoresizesSubviews = YES; + [self addSubview:_contentContainer]; [self setBackgroundColor:[UIColor colorWithWhite:0.0 alpha:0.5]]; // Fixed value, the bacground mask. - [self.contentView setBackgroundColor:[UIColor clearColor]]; - self.delegate = nil; + [_contentView setBackgroundColor:[UIColor clearColor]]; self.tag = (arc4random() % 32768); @@ -63,19 +57,6 @@ - (id)initWithFrame:(CGRect)frame { return self; } -- (void)dealloc { - self.roundedRect = nil; - self.closeButton = nil; - self.actionButton = nil; - self.contentContainer = nil; - self.borderColor = nil; - self.contentColor = nil; - self.onActionPressed = nil; - self.onClosePressed = nil; - self.delegate = nil; - [super dealloc]; -} - #pragma mark - Description - (NSString *)description { @@ -85,58 +66,52 @@ - (NSString *)description { #pragma mark - Accessors - (void)setCornerRadius:(CGFloat)newRadius { - cornerRadius = newRadius; - self.roundedRect.layer.cornerRadius = cornerRadius; + _cornerRadius = newRadius; + self.roundedRect.layer.cornerRadius = self.cornerRadius; } - (void)setBorderWidth:(CGFloat)newWidth { - borderWidth = newWidth; - self.roundedRect.layer.borderWidth = borderWidth; + _borderWidth = newWidth; + self.roundedRect.layer.borderWidth = self.borderWidth; } - (void)setBorderColor:(UIColor *)newColor { - [newColor retain]; - [borderColor release]; - borderColor = newColor; - - self.roundedRect.layer.borderColor = [borderColor CGColor]; + _borderColor = newColor; + self.roundedRect.layer.borderColor = [self.borderColor CGColor]; } - (void)setContentColor:(UIColor *)newColor { - [newColor retain]; - [contentColor release]; - contentColor = newColor; - - self.roundedRect.backgroundColor = contentColor; + _contentColor = newColor; + self.roundedRect.backgroundColor = self.contentColor; } - (UIView *)roundedRect { - if (!roundedRect) { - self.roundedRect = [[[UIView alloc] initWithFrame:CGRectZero] autorelease]; - self.roundedRect.layer.masksToBounds = YES; - self.roundedRect.backgroundColor = self.contentColor; - self.roundedRect.layer.borderColor = [self.borderColor CGColor]; - self.roundedRect.layer.borderWidth = self.borderWidth; - self.roundedRect.layer.cornerRadius = self.cornerRadius; - - [self.contentContainer insertSubview:self.roundedRect atIndex:0]; + if (!_roundedRect) { + _roundedRect = [[UIView alloc] initWithFrame:CGRectZero]; + _roundedRect.layer.masksToBounds = YES; + _roundedRect.backgroundColor = self.contentColor; + _roundedRect.layer.borderColor = [self.borderColor CGColor]; + _roundedRect.layer.borderWidth = self.borderWidth; + _roundedRect.layer.cornerRadius = self.cornerRadius; + + [self.contentContainer insertSubview:_roundedRect atIndex:0]; } - return roundedRect; + return _roundedRect; } - (UIButton*)closeButton { - if (!closeButton) { - self.closeButton = [UIButton buttonWithType:UIButtonTypeCustom]; - [self.closeButton setImage:[UIImage imageNamed:@"close.png"] forState:UIControlStateNormal]; - [self.closeButton setFrame:CGRectMake(0, 0, 44, 44)]; - self.closeButton.layer.shadowColor = [[UIColor blackColor] CGColor]; - self.closeButton.layer.shadowOffset = CGSizeMake(0,4); - self.closeButton.layer.shadowOpacity = 0.3; + if (!_closeButton) { + _closeButton = [UIButton buttonWithType:UIButtonTypeCustom]; + [_closeButton setImage:[UIImage imageNamed:@"close.png"] forState:UIControlStateNormal]; + [_closeButton setFrame:CGRectMake(0, 0, 44, 44)]; + _closeButton.layer.shadowColor = [[UIColor blackColor] CGColor]; + _closeButton.layer.shadowOffset = CGSizeMake(0,4); + _closeButton.layer.shadowOpacity = 0.3; - [closeButton addTarget:self action:@selector(closePressed:) forControlEvents:UIControlEventTouchUpInside]; - [self.contentContainer insertSubview:closeButton aboveSubview:self.contentView]; + [_closeButton addTarget:self action:@selector(closePressed:) forControlEvents:UIControlEventTouchUpInside]; + [self.contentContainer insertSubview:_closeButton aboveSubview:self.contentView]; } - return closeButton; + return _closeButton; } - (UIButton*)actionButton { - if (!actionButton) { + if (!_actionButton) { UIImage *image = [UIImage imageNamed:@"modalButton.png"]; UIImage *stretch = (([UIImage respondsToSelector:@selector(resizableImageWithCapInsets:)]) ? [image resizableImageWithCapInsets:UIEdgeInsetsMake(0, image.size.width/2.0, 0, image.size.width/2.0)] : @@ -145,31 +120,31 @@ - (UIButton*)actionButton { UIImage *stretch2 = (([UIImage respondsToSelector:@selector(resizableImageWithCapInsets:)]) ? [image2 resizableImageWithCapInsets:UIEdgeInsetsMake(0, image2.size.width/2.0, 0, image2.size.width/2.0)] : [image stretchableImageWithLeftCapWidth:image2.size.width/2.0 topCapHeight:image2.size.width/2.0]); - self.actionButton = [UIButton buttonWithType:UIButtonTypeCustom]; - [self.actionButton setBackgroundImage:stretch forState:UIControlStateNormal]; - [self.actionButton setBackgroundImage:stretch2 forState:UIControlStateHighlighted]; - self.actionButton.layer.shadowColor = [[UIColor blackColor] CGColor]; - self.actionButton.layer.shadowOffset = CGSizeMake(0,4); - self.actionButton.layer.shadowOpacity = 0.3; - self.actionButton.titleLabel.font = [UIFont boldSystemFontOfSize:11]; - [self.actionButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; - [self.actionButton setTitleColor:[UIColor grayColor] forState:UIControlStateHighlighted]; - self.actionButton.contentEdgeInsets = UIEdgeInsetsMake(4, 8, 4, 8); + _actionButton = [UIButton buttonWithType:UIButtonTypeCustom]; + [_actionButton setBackgroundImage:stretch forState:UIControlStateNormal]; + [_actionButton setBackgroundImage:stretch2 forState:UIControlStateHighlighted]; + _actionButton.layer.shadowColor = [[UIColor blackColor] CGColor]; + _actionButton.layer.shadowOffset = CGSizeMake(0,4); + _actionButton.layer.shadowOpacity = 0.3; + _actionButton.titleLabel.font = [UIFont boldSystemFontOfSize:11]; + [_actionButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; + [_actionButton setTitleColor:[UIColor grayColor] forState:UIControlStateHighlighted]; + _actionButton.contentEdgeInsets = UIEdgeInsetsMake(4, 8, 4, 8); - [actionButton addTarget:self action:@selector(actionPressed:) forControlEvents:UIControlEventTouchUpInside]; - [self.contentContainer insertSubview:actionButton aboveSubview:self.contentView]; + [_actionButton addTarget:self action:@selector(actionPressed:) forControlEvents:UIControlEventTouchUpInside]; + [self.contentContainer insertSubview:_actionButton aboveSubview:self.contentView]; } - return actionButton; + return _actionButton; } - (UIView *)contentView { - if (!contentView) { - self.contentView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease]; - self.contentView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight; - self.contentView.autoresizesSubviews = YES; - [self.contentContainer insertSubview:contentView aboveSubview:self.roundedRect]; + if (!_contentView) { + _contentView = [[UIView alloc] initWithFrame:CGRectZero]; + _contentView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight; + _contentView.autoresizesSubviews = YES; + [self.contentContainer insertSubview:_contentView aboveSubview:self.roundedRect]; } - return contentView; + return _contentView; } - (CGRect)roundedRectFrame { @@ -182,10 +157,10 @@ - (CGRect)roundedRectFrame { - (CGRect)closeButtonFrame { CGRect f = [self roundedRectFrame]; - return CGRectMake(f.origin.x - floor(closeButton.frame.size.width*0.5), - f.origin.y - floor(closeButton.frame.size.height*0.5), - closeButton.frame.size.width, - closeButton.frame.size.height); + return CGRectMake(f.origin.x - floor(self.closeButton.frame.size.width*0.5), + f.origin.y - floor(self.closeButton.frame.size.height*0.5), + self.closeButton.frame.size.width, + self.closeButton.frame.size.height); } - (CGRect)actionButtonFrame { @@ -195,7 +170,7 @@ - (CGRect)actionButtonFrame { [self.actionButton sizeToFit]; CGRect f = [self roundedRectFrame]; return CGRectMake(f.origin.x + f.size.width - self.actionButton.frame.size.width + 11, - f.origin.y - floor(actionButton.frame.size.height*0.5), + f.origin.y - floor(self.actionButton.frame.size.height*0.5), self.actionButton.frame.size.width, self.actionButton.frame.size.height); } @@ -224,8 +199,8 @@ - (void)layoutSubviews { - (void)closePressed:(id)sender { // Using Delegates - if ([delegate respondsToSelector:@selector(shouldCloseModalPanel:)]) { - if ([delegate shouldCloseModalPanel:self]) { + if ([self.delegate respondsToSelector:@selector(shouldCloseModalPanel:)]) { + if ([self.delegate shouldCloseModalPanel:self]) { UADebugLog(@"Closing using delegates for modalPanel: %@", self); [self hide]; } @@ -246,8 +221,8 @@ - (void)closePressed:(id)sender { - (void)actionPressed:(id)sender { // Using Delegates - if ([delegate respondsToSelector:@selector(didSelectActionButton:)]) { - [delegate didSelectActionButton:self]; + if ([self.delegate respondsToSelector:@selector(didSelectActionButton:)]) { + [self.delegate didSelectActionButton:self]; // Using blocks @@ -261,7 +236,6 @@ - (void)actionPressed:(id)sender { } } - - (void)showAnimationStarting {}; //subclasses override - (void)showAnimationPart1Finished {}; //subclasses override - (void)showAnimationPart2Finished {}; //subclasses override @@ -269,8 +243,8 @@ - (void)showAnimationPart3Finished {}; //subclasses override - (void)showAnimationFinished {}; //subclasses override - (void)show { - if ([delegate respondsToSelector:@selector(willShowModalPanel:)]) - [delegate willShowModalPanel:self]; + if ([self.delegate respondsToSelector:@selector(willShowModalPanel:)]) + [self.delegate willShowModalPanel:self]; [self showAnimationStarting]; self.alpha = 0.0; @@ -302,8 +276,8 @@ - (void)show { } completion:^(BOOL finished){ [self showAnimationFinished]; - if ([delegate respondsToSelector:@selector(didShowModalPanel:)]) - [delegate didShowModalPanel:self]; + if ([self.delegate respondsToSelector:@selector(didShowModalPanel:)]) + [self.delegate didShowModalPanel:self]; }]; }]; }]; @@ -316,37 +290,37 @@ - (void)show { animations:^{ self.alpha = 1.0; self.contentContainer.center = self.center; - self.contentContainer.transform = CGAffineTransformMakeScale((shouldBounce ? 1.05 : 1.0), (shouldBounce ? 1.05 : 1.0)); + self.contentContainer.transform = CGAffineTransformMakeScale((self.shouldBounce ? 1.05 : 1.0), (self.shouldBounce ? 1.05 : 1.0)); } - completion:(shouldBounce ? animationBlock : ^(BOOL finished) { + completion:(self.shouldBounce ? animationBlock : ^(BOOL finished) { [self showAnimationFinished]; - if ([delegate respondsToSelector:@selector(didShowModalPanel:)]) - [delegate didShowModalPanel:self]; + if ([self.delegate respondsToSelector:@selector(didShowModalPanel:)]) + [self.delegate didShowModalPanel:self]; })]; } - (void)showFromPoint:(CGPoint)point { - startEndPoint = point; + self.startEndPoint = point; self.contentContainer.center = point; [self show]; } - (void)hide { // Hide the view right away - if ([delegate respondsToSelector:@selector(willCloseModalPanel:)]) - [delegate willCloseModalPanel:self]; + if ([self.delegate respondsToSelector:@selector(willCloseModalPanel:)]) + [self.delegate willCloseModalPanel:self]; [UIView animateWithDuration:0.3 animations:^{ self.alpha = 0; - if (startEndPoint.x != CGPointZero.x || startEndPoint.y != CGPointZero.y) { - self.contentContainer.center = startEndPoint; + if (self.startEndPoint.x != CGPointZero.x || self.startEndPoint.y != CGPointZero.y) { + self.contentContainer.center = self.startEndPoint; } self.contentContainer.transform = CGAffineTransformMakeScale(0.0001, 0.0001); } completion:^(BOOL finished){ - if ([delegate respondsToSelector:@selector(didCloseModalPanel:)]) { - [delegate didCloseModalPanel:self]; + if ([self.delegate respondsToSelector:@selector(didCloseModalPanel:)]) { + [self.delegate didCloseModalPanel:self]; } [self removeFromSuperview]; }]; @@ -358,8 +332,8 @@ - (void)hideWithOnComplete:(UAModalDisplayPanelAnimationComplete)onComplete { [UIView animateWithDuration:0.3 animations:^{ self.alpha = 0; - if (startEndPoint.x != CGPointZero.x || startEndPoint.y != CGPointZero.y) { - self.contentContainer.center = startEndPoint; + if (self.startEndPoint.x != CGPointZero.x || self.startEndPoint.y != CGPointZero.y) { + self.contentContainer.center = self.startEndPoint; } self.contentContainer.transform = CGAffineTransformMakeScale(0.0001, 0.0001); } diff --git a/UAModalPanel/Panel/Panels/UATitledModalPanel.h b/UAModalPanel/Panel/Panels/UATitledModalPanel.h old mode 100644 new mode 100755 index 71213c9..8ed7e8f --- a/UAModalPanel/Panel/Panels/UATitledModalPanel.h +++ b/UAModalPanel/Panel/Panels/UATitledModalPanel.h @@ -10,20 +10,14 @@ #import "UAModalPanel.h" #import "UANoisyGradientBackground.h" -@interface UATitledModalPanel : UAModalPanel { - - CGFloat titleBarHeight; - UANoisyGradientBackground *titleBar; - UILabel *headerLabel; - -} +@interface UATitledModalPanel : UAModalPanel // Height of the title view. Default = 40.0f @property (nonatomic, assign) CGFloat titleBarHeight; // The gradient bacground of the title -@property (nonatomic, retain) UANoisyGradientBackground *titleBar; +@property (nonatomic, strong) UANoisyGradientBackground *titleBar; // The title label -@property (nonatomic, retain) UILabel *headerLabel; +@property (nonatomic, strong) UILabel *headerLabel; - (CGRect)titleBarFrame; diff --git a/UAModalPanel/Panel/Panels/UATitledModalPanel.m b/UAModalPanel/Panel/Panels/UATitledModalPanel.m old mode 100644 new mode 100755 index 8e42b3d..5815f1c --- a/UAModalPanel/Panel/Panels/UATitledModalPanel.m +++ b/UAModalPanel/Panel/Panels/UATitledModalPanel.m @@ -13,14 +13,6 @@ @implementation UATitledModalPanel -@synthesize titleBarHeight, titleBar, headerLabel; - -- (void)dealloc { - self.titleBar = nil; - self.headerLabel = nil; - [super dealloc]; -} - - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { @@ -37,7 +29,7 @@ - (id)initWithFrame:(CGRect)frame { [self.roundedRect addSubview:self.titleBar]; - self.headerLabel = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease]; + self.headerLabel = [[UILabel alloc] initWithFrame:CGRectZero]; self.headerLabel.font = [UIFont systemFontOfSize:24]; self.headerLabel.backgroundColor = [UIColor clearColor]; self.headerLabel.textColor = [UIColor whiteColor]; diff --git a/UAModalPanel/Panel/Views/UAGradientBackground.m b/UAModalPanel/Panel/Views/UAGradientBackground.m index e1bad15..6126dae 100755 --- a/UAModalPanel/Panel/Views/UAGradientBackground.m +++ b/UAModalPanel/Panel/Views/UAGradientBackground.m @@ -42,16 +42,16 @@ - (id)initWithFrame:(CGRect)frame { + (id)gradientWithFrame:(CGRect)frame style:(UAGradientBackgroundStyle)aStyle color:(CGFloat *)components lineMode:(UAGradientLineMode)lineModes { - return [[[UAGradientBackground alloc] initWithFrame:frame style:aStyle color:components lineMode:lineModes] autorelease]; + return [[UAGradientBackground alloc] initWithFrame:frame style:aStyle color:components lineMode:lineModes]; } + (id)gradientWithFrame:(CGRect)frame color:(CGFloat *)components { - return [[(UAGradientBackground *)[UAGradientBackground alloc] initWithFrame:frame color:components] autorelease]; + return [(UAGradientBackground *)[UAGradientBackground alloc] initWithFrame:frame color:components]; } + (id)gradientWithFrame:(CGRect)frame style:(UAGradientBackgroundStyle)aStyle { - return [[[UAGradientBackground alloc] initWithFrame:frame style:aStyle] autorelease]; + return [[UAGradientBackground alloc] initWithFrame:frame style:aStyle]; } + (id)gradientWithFrame:(CGRect)frame; { - return [[[UAGradientBackground alloc] initWithFrame:frame] autorelease]; + return [[UAGradientBackground alloc] initWithFrame:frame]; } @@ -133,7 +133,6 @@ - (void)drawRect:(CGRect)rect { - (void)dealloc { NSZoneFree(NSDefaultMallocZone(), colorComponents); - [super dealloc]; } diff --git a/UAModalPanel/Panel/Views/UANoisyGradientBackground.m b/UAModalPanel/Panel/Views/UANoisyGradientBackground.m old mode 100644 new mode 100755 index 6b36349..a0e71ec --- a/UAModalPanel/Panel/Views/UANoisyGradientBackground.m +++ b/UAModalPanel/Panel/Views/UANoisyGradientBackground.m @@ -50,18 +50,18 @@ - (id)initWithFrame:(CGRect)frame { + (id)gradientWithFrame:(CGRect)frame style:(UAGradientBackgroundStyle)aStyle color:(CGFloat *)components lineMode:(UAGradientLineMode)lineModes noiseOpacity:(CGFloat)opacity blendMode:(CGBlendMode)mode { - return [[[UANoisyGradientBackground alloc] initWithFrame:frame + return [[UANoisyGradientBackground alloc] initWithFrame:frame style:aStyle color:components lineMode:lineModes noiseOpacity:opacity - blendMode:mode] autorelease]; + blendMode:mode]; } + (id)gradientWithFrame:(CGRect)frame noiseOpacity:(CGFloat)noiseOpacity { - return [[[UANoisyGradientBackground alloc] initWithFrame:frame noiseOpacity:noiseOpacity] autorelease]; + return [[UANoisyGradientBackground alloc] initWithFrame:frame noiseOpacity:noiseOpacity]; } + (id)gradientWithFrame:(CGRect)frame blendMode:(CGFloat)mode { - return [[[UANoisyGradientBackground alloc] initWithFrame:frame blendMode:mode] autorelease]; + return [[UANoisyGradientBackground alloc] initWithFrame:frame blendMode:mode]; } diff --git a/UAModalPanel/Panel/Views/UARoundedRectView.m b/UAModalPanel/Panel/Views/UARoundedRectView.m index 276f2e0..095358b 100755 --- a/UAModalPanel/Panel/Views/UARoundedRectView.m +++ b/UAModalPanel/Panel/Views/UARoundedRectView.m @@ -50,7 +50,6 @@ - (void)setRadius:(NSInteger)rad { - (void)dealloc { NSZoneFree(NSDefaultMallocZone(), colorComponents); - [super dealloc]; }