Skip to content

Commit 932c553

Browse files
committed
add shadowRadius property
1 parent 4ae22ca commit 932c553

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

SIAlertView/SIAlertView.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ typedef void(^SIAlertViewHandler)(SIAlertView *alertView);
5050
@property (nonatomic, strong) UIFont *titleFont NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;
5151
@property (nonatomic, strong) UIFont *messageFont NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;
5252
@property (nonatomic, strong) UIFont *buttonFont NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;
53-
@property (nonatomic, assign) CGFloat cornerRadius NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;
53+
@property (nonatomic, assign) CGFloat cornerRadius NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR; // default is 2.0
54+
@property (nonatomic, assign) CGFloat shadowRadius NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR; // default is 8.0
5455

5556
- (id)initWithTitle:(NSString *)title andMessage:(NSString *)message;
5657
- (void)addButtonWithTitle:(NSString *)title type:(SIAlertViewButtonType)type handler:(SIAlertViewHandler)handler;

SIAlertView/SIAlertView.m

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ + (void)initialize
172172
appearance.messageFont = [UIFont systemFontOfSize:16];
173173
appearance.buttonFont = [UIFont systemFontOfSize:[UIFont buttonFontSize]];
174174
appearance.cornerRadius = 2;
175+
appearance.shadowRadius = 8;
175176
}
176177

177178
- (id)init
@@ -739,7 +740,7 @@ - (void)setupContainerView
739740
self.containerView.backgroundColor = [UIColor whiteColor];
740741
self.containerView.layer.cornerRadius = self.cornerRadius;
741742
self.containerView.layer.shadowOffset = CGSizeZero;
742-
self.containerView.layer.shadowRadius = 8;
743+
self.containerView.layer.shadowRadius = self.shadowRadius;
743744
self.containerView.layer.shadowOpacity = 0.5;
744745
[self addSubview:self.containerView];
745746
}
@@ -927,4 +928,13 @@ - (void)setCornerRadius:(CGFloat)cornerRadius
927928
self.containerView.layer.cornerRadius = cornerRadius;
928929
}
929930

931+
- (void)setShadowRadius:(CGFloat)shadowRadius
932+
{
933+
if (_shadowRadius == shadowRadius) {
934+
return;
935+
}
936+
_shadowRadius = shadowRadius;
937+
self.containerView.layer.shadowRadius = shadowRadius;
938+
}
939+
930940
@end

SIAlertViewExample/SIAlertViewExample/ViewController.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ - (void)viewDidLoad
2323
[[SIAlertView appearance] setTitleColor:[UIColor greenColor]];
2424
[[SIAlertView appearance] setMessageColor:[UIColor purpleColor]];
2525
[[SIAlertView appearance] setCornerRadius:12];
26+
[[SIAlertView appearance] setShadowRadius:20];
2627
}
2728

2829
#pragma mark - Actions

0 commit comments

Comments
 (0)