CGRect frame;       
UIButton *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 {
//在这里实现按钮的单击事件
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2021-09-18
  • 2021-06-12
  • 2022-12-23
  • 2022-12-23
  • 2021-09-04
猜你喜欢
  • 2021-06-10
  • 2021-05-19
  • 2022-12-23
  • 2021-12-09
  • 2021-12-20
  • 2021-11-28
  • 2022-12-23
相关资源
相似解决方案