Change on flash button style, icon and position

This commit is contained in:
micaTewe 2015-09-17 03:17:07 +02:00 committed by Daniel Cousens
parent d6742f03d9
commit 7d7d03a1cc

View File

@ -19,14 +19,39 @@
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
[button setTitle:@"Turn on Flash" forState:UIControlStateNormal];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
//[button setTitle:@"Flash" forState:UIControlStateNormal];
[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
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];
[self.view addSubview:button];
}
- (void)didReceiveMemoryWarning {
@ -38,8 +63,8 @@
CsZBar *obj = [[CsZBar alloc] init];
[obj toggleflash];
[obj toggleflash];
}
@ -69,13 +94,13 @@
}
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end