Change on flash button style, icon and position
This commit is contained in:
parent
d6742f03d9
commit
7d7d03a1cc
@ -19,12 +19,37 @@
|
|||||||
- (void)viewDidLoad {
|
- (void)viewDidLoad {
|
||||||
[super viewDidLoad];
|
[super viewDidLoad];
|
||||||
// Do any additional setup after loading the view.
|
// Do any additional setup after loading the view.
|
||||||
UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
|
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
|
||||||
[button setTitle:@"Turn on Flash" forState:UIControlStateNormal];
|
//[button setTitle:@"Flash" forState:UIControlStateNormal];
|
||||||
[button sizeToFit];
|
[button sizeToFit];
|
||||||
|
CGRect screenRect = [[UIScreen mainScreen] bounds];
|
||||||
|
//[button setContentEdgeInsets:UIEdgeInsetsMake(20, 30, 20, 30)];
|
||||||
|
CGRect frame;
|
||||||
|
if(screenRect.size.height>(screenRect.size.width)){
|
||||||
|
frame = CGRectMake(0,0, screenRect.size.width*(0.15), screenRect.size.height*0.15);
|
||||||
|
|
||||||
|
//button.center = CGPointMake( 0,0);
|
||||||
|
}else{
|
||||||
|
frame = CGRectMake(0,0, screenRect.size.width*(0.10), screenRect.size.height*0.20);
|
||||||
|
|
||||||
|
//button.center = CGPointMake(0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
button.frame =frame;
|
||||||
|
button.layer.cornerRadius = 10;
|
||||||
|
button.clipsToBounds = YES;
|
||||||
// Set a new (x,y) point for the button's center
|
// Set a new (x,y) point for the button's center
|
||||||
button.center = CGPointMake(320/2, 60);
|
|
||||||
|
UIImage *btnImage = [UIImage imageNamed:@"flash.png"];
|
||||||
|
|
||||||
|
[button setImage:btnImage forState:UIControlStateNormal];
|
||||||
|
[button setBackgroundColor: [UIColor blackColor] ];
|
||||||
|
|
||||||
|
//[button setBackgroundColor:[UIColor colorWithRed:.859 green:.765 blue:.616 alpha:1.0] forState:UIControlStateHighlighted];
|
||||||
|
|
||||||
|
//button.center = CGPointMake( 0,0);
|
||||||
[button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
|
[button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
|
||||||
|
|
||||||
[self.view addSubview:button];
|
[self.view addSubview:button];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user