首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

自定义旋钮

2012-06-29 
自定义按钮UIButton *BtnCGRect frameBtn [[UIButton buttonWithType:UIButtonTypeCustom] retain] /

自定义按钮

UIButton *Btn;CGRect frame;Btn = [[UIButton buttonWithType:UIButtonTypeCustom] retain]; //按钮的类型        [Btn setImage:[UIImage imageNamed:@“aaa.png”]forState:UIControlStateNormal];//设置按钮图片    Btn.tag = 10;    frame.size.width = 59;  //设置按钮的宽度    frame.size.height = 59;   //设置按钮的高度        frame.origin.x =150;   //设置按钮的位置        frame.origin.y =260;        [Btn setFrame:frame];        [Btn setBackgroundColor:[UIColor clearColor]];          [Btn addTarget:self action:@selector(btnPressed:)forControlEvents:UIControlEventTouchUpInside];   //按钮的单击事件        [self.view addSubview:Btn];          [Btn release];-(void)btnPressed:(id)sender {//在这里实现按钮的单击事件}

热点排行