Quantcast
Channel: Notes of a Developer » work
Viewing all articles
Browse latest Browse all 10

Color Picker for iOS

$
0
0

Example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
- (void)viewDidLoad
{
    [super viewDidLoad];
   
    // Do any additional setup after loading the view, typically from a nib.
   
    if (self.cPicker == nil) {
        [self.view setBackgroundColor:[UIColor grayColor]];
        self.cPicker = [[VBColorPicker alloc] initWithFrame:CGRectMake(0, 0, 202, 202)];
        [_cPicker setCenter:self.view.center];
        [self.view addSubview:_cPicker];
        [_cPicker setDelegate:self];
        [_cPicker showPicker];
       
        // set default YES!
        [_cPicker setHideAfterSelection:NO];
    }
     
}

// set color from picker
- (void) pickedColor:(UIColor *)color {
    [_rect setBackgroundColor:color];
    [_cPicker hidePicker];
}

- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    if (![_cPicker isHidden]) {
        [_cPicker hidePicker];
    }
}

// show picker by double touch
- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
   
    if (touch.tapCount == 2) {
        [_cPicker setCenter:[touch locationInView:self.view]];
        [_cPicker showPicker];
    }
}

The post Color Picker for iOS appeared first on Notes of a Developer.


Viewing all articles
Browse latest Browse all 10

Latest Images

Trending Articles





Latest Images