Skip to content

Instantly share code, notes, and snippets.

@20m61
Created December 3, 2012 03:11
Show Gist options
  • Save 20m61/4192394 to your computer and use it in GitHub Desktop.
Save 20m61/4192394 to your computer and use it in GitHub Desktop.
ボタンの配置
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
float valueR = 1.;
float valueG = 1.;
float valueB = 1.;
float valueAlpha = 1.;
int center = self.view.frame.size.width / 2;
int bottom = self.view.frame.size.height;
int bottunWIdth = 50;
int bottunheight = 20;
int bottomMargin = 50;
int buttonMargine = 20;
#pragma mark - buttonR
//https://gist.github.com/1f6932ec3b8407c4c409
UIButton *buttonRPlus =
[UIButton buttonWithType:100];
[buttonRPlus setTitle:@"R+" forState:UIControlStateNormal];
buttonRPlus.frame =
CGRectMake(center - bottunWIdth / 2 - buttonMargine - bottunWIdth, bottom - bottomMargin - bottunheight - buttonMargine, bottunWIdth, bottunheight);
buttonRPlus.tintColor = [UIColor colorWithRed:valueR green:1. blue:1. alpha:1.];
[self.view addSubview:buttonRPlus];
UIButton *buttonRMinus =
[UIButton buttonWithType:100];
[buttonRMinus setTitle:@"G-" forState:UIControlStateNormal];
buttonRMinus.frame = CGRectMake(center - bottunWIdth / 2 - buttonMargine - bottunWIdth, bottom - bottomMargin, bottunWIdth, bottunheight);
buttonRMinus.tintColor = [UIColor colorWithRed:valueR green:1. blue:1. alpha:1.];
[self.view addSubview:buttonRMinus];
#pragma mark - buttonG
UIButton *buttonGPlus =
[UIButton buttonWithType:100];
[buttonGPlus setTitle:@"G+" forState:UIControlStateNormal];
buttonGPlus.frame =
CGRectMake(center - bottunWIdth / 2, bottom - bottomMargin - bottunheight - buttonMargine, bottunWIdth, bottunheight);
buttonGPlus.tintColor = [UIColor colorWithRed:1. green:valueG blue:1. alpha:1.];
[self.view addSubview:buttonGPlus];
UIButton *buttonGMinus =
[UIButton buttonWithType:100];
[buttonGMinus setTitle:@"G-" forState:UIControlStateNormal];
buttonGMinus.frame = CGRectMake(center - bottunWIdth / 2, bottom - bottomMargin, bottunWIdth, bottunheight);
buttonGMinus.tintColor = [UIColor colorWithRed:1. green:valueG blue:1. alpha:1.];
[self.view addSubview:buttonGMinus];
#pragma mark - buttonB
UIButton *buttonBPlus =
[UIButton buttonWithType:100];
[buttonBPlus setTitle:@"B+" forState:UIControlStateNormal];
buttonBPlus.frame =
CGRectMake(center - bottunWIdth / 2 + buttonMargine + bottunWIdth, bottom - bottomMargin - bottunheight - buttonMargine, bottunWIdth, bottunheight);
buttonBPlus.tintColor = [UIColor colorWithRed:1. green:1. blue:valueB alpha:1.];
[self.view addSubview:buttonBPlus];
UIButton *buttonBMinus =
[UIButton buttonWithType:100];
[buttonBMinus setTitle:@"B-" forState:UIControlStateNormal];
buttonBMinus.frame = CGRectMake(center - bottunWIdth / 2 + buttonMargine + bottunWIdth, bottom - bottomMargin, bottunWIdth, bottunheight);
buttonBMinus.tintColor = [UIColor colorWithRed:1. green:1. blue:valueB alpha:1.];
[self.view addSubview:buttonBMinus];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment