sgl0v / MSColorPicker

Color picker component for iOS
MIT License
190 stars 29 forks source link

Returned color is always 100% transparent #1

Closed pronebird closed 9 years ago

pronebird commented 9 years ago

Demo works though.

- (IBAction)changeColor:(id)sender {
    MSColorSelectionViewController *controller = [[MSColorSelectionViewController alloc] init];
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:controller];

    UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Done", ) style:UIBarButtonItemStyleDone target:self action:@selector(dismissColorPicker:)];
    controller.navigationItem.rightBarButtonItem = doneBtn;

    controller.delegate = self;
    controller.color = self.view.tintColor;

    [self presentViewController:navigationController animated:YES completion:nil];
}

- (void)dismissColorPicker:(id)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)colorViewController:(MSColorSelectionViewController *)colorViewCntroller didChangeColor:(UIColor *)color {
    self.view.window.tintColor = color;
    colorViewCntroller.view.window.tintColor = color;
}
pronebird commented 9 years ago

If you look at the setColor setter, it proxies color value to subview which is not created yet. Your demo works because you force viewDidLoad by using .view property of color selection controller.

It would make sense to retain the initial color and pass it to subview in viewDidLoad.

sgl0v commented 9 years ago

Fixed this issue in version 0.2.1 . In the end I decided to force a view creation in setColor method.