Skip to content

Commit

Permalink
Merge pull request #287 from skywinder/toolbar-color
Browse files Browse the repository at this point in the history
Add ability to set toolbar color via toolbarBackgroundColor property
  • Loading branch information
skywinder authored Jun 27, 2016
2 parents b2f6c85 + 75f1101 commit 00bd1e6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ - (IBAction)customButtons:(id)sender {
- (IBAction)customBackgroundAndText:(id)sender {
ActionSheetStringPicker *picker = [[ActionSheetStringPicker alloc] initWithTitle:@"" rows:@[@"choiceA", @"choiceB", @"choiceC"] initialSelection:1 doneBlock:nil cancelBlock:nil origin:sender];
picker.pickerBackgroundColor = [UIColor blackColor];
picker.toolbar.backgroundColor = [UIColor blackColor];
NSMutableParagraphStyle *labelParagraphStyle = [[NSMutableParagraphStyle alloc] init];
labelParagraphStyle.alignment = NSTextAlignmentCenter;
picker.pickerTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,21 @@ class SWTableViewController: UITableViewController, UITextFieldDelegate {
["Many", "Many more", "Infinite"]
], initialSelection: [2, 2], doneBlock: {
picker, values, indexes in

print("values = \(values)")
print("indexes = \(indexes)")
print("picker = \(picker)")
return
}, cancelBlock: { ActionMultipleStringCancelBlock in return }, origin: sender)


acp.setTextColor(UIColor.redColor())

acp.pickerBackgroundColor = UIColor.blackColor()

acp.toolbarBackgroundColor = UIColor.yellowColor()

acp.showActionSheetPicker()
}


func datePicked(obj: NSDate) {
UIDatePickerModeTime.setTitle(obj.description, forState: UIControlState.Normal)
Expand Down
1 change: 1 addition & 0 deletions Pickers/AbstractActionSheetPicker.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ static NSString *const kActionTarget = @"buttonActionTarget";
@property(nonatomic) NSAttributedString *attributedTitle; // default is nil. If titleTextAttributes not nil this value ignored.
@property(nonatomic) NSMutableDictionary *pickerTextAttributes; // default with a NSMutableParagraphStyle to set label align center. Used to specify Picker Label attributes.
@property(nonatomic) UIColor *pickerBackgroundColor;
@property(nonatomic) UIColor *toolbarBackgroundColor;
@property(nonatomic) NSNumber *pickerBlurRadius;
@property(nonatomic, retain) Class popoverBackgroundViewClass; //allow popover customization on iPad
@property(nonatomic) UIInterfaceOrientationMask supportedInterfaceOrientations; // You can set your own supportedInterfaceOrientations value to prevent dismissing picker in some special cases.
Expand Down
4 changes: 3 additions & 1 deletion Pickers/AbstractActionSheetPicker.m
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ - (void)showActionSheetPicker {
}
[masterView addSubview:_pickerView];

if ((![MyPopoverController canShowPopover] || self.popoverDisabled) && !self.pickerBackgroundColor && [self.pickerBlurRadius intValue] > 0) {
if ((![MyPopoverController canShowPopover] || self.popoverDisabled) && !self.pickerBackgroundColor && !self.toolbarBackgroundColor && [self.pickerBlurRadius intValue] > 0) {
[self blurPickerBackground];
} else {
[self presentPickerForView:masterView];
Expand Down Expand Up @@ -472,6 +472,8 @@ - (UIToolbar *)createPickerToolbarWithTitle:(NSString *)title {
UIToolbar *pickerToolbar = [[UIToolbar alloc] initWithFrame:frame];
pickerToolbar.barStyle = (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1) ? UIBarStyleDefault : UIBarStyleBlackTranslucent;

pickerToolbar.barTintColor = self.toolbarBackgroundColor;

NSMutableArray *barItems = [[NSMutableArray alloc] init];

if (!self.hideCancel) {
Expand Down

0 comments on commit 00bd1e6

Please sign in to comment.