Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to set toolbar color via toolbarBackgroundColor property #287

Merged
merged 1 commit into from
Jun 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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