【发布时间】:2013-03-21 11:53:58
【问题描述】:
我搜索了一些教程,将 UIImage 添加到按钮以进行点击事件。如何添加 URL 路径
图像到按钮..例如代码:
UIButton *imageView=[[UIButton alloc]initWithFrame:CGRectMake((320*index)+countFlag*80+ 2, 5, 75, 75)];
imageView.tag=i+1;
[imageView addTarget:self action:@selector(imageViewClicked:) forControlEvents:UIControlEventTouchUpInside];
[imageView.layer setBorderColor:[UIColor lightGrayColor].CGColor];
[imageView.layer setBorderWidth:1.0f];
switch ((i+1)%5) {
case 0:
[imageView setImage:[UIImage imageNamed:@"img1.png"] forState:UIControlStateNormal];
break;
case 1:
[imageView setImage:[UIImage imageNamed:@"img2.png"] forState:UIControlStateNormal];
break;
}
【问题讨论】:
-
你想用背景图片显示按钮吗?
-
使用 EGOButton 作为 URL。
标签: iphone objective-c image url uibutton