iphone九宫格算法
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px} p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #40207c} p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #008324} span.s1 {color: #743fa4} span.s2 {color: #40207c} span.s3 {color: #d62c24} span.s4 {color: #c02d9d} span.s5 {color: #2f2fd0} span.s6 {color: #000000} span.s7 {color: #008324} span.s8 {font: 11.0px 'Heiti SC Light'; color: #008324}
NSArray* imageNames = [NSArray arrayWithObjects:
@"ico_mobile.png",
@"ico_idcard.png",
@"ico_postcode.png",
@"ico_flight.png",
@"ico_translate.png",
@"ico_phone.png",
@"ico_car.png",
@"ico_health.png",
@"ico_bjxm.png", nil];
UIButton *Btn;
for (int i=0; i<9; i++) {
CGRect frame;
Btn = [[UIButton buttonWithType: UIButtonTypeRoundedRect] retain];
[Btn setImage:[UIImage imageNamed:[imageNames objectAtIndex: i]] forState:UIControlStateNormal];//设置按钮图片
Btn.tag = i;
frame.size.width = 59;//设置按钮坐标及大小
frame.size.height = 75;
frame.origin.x = (i%3)*(59+32)+40;
frame.origin.y = floor(i/3)*(75+24)+40;
[Btn setFrame:frame];
[Btn setBackgroundColor:[UIColor clearColor]];
// [Btn addTarget:self action:@selector(btnPressed:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:Btn];
[Btn release];