根据tag获取控件,并且根据两个控件的tag交换控件图片
/**
* 移动
*/
-(void)remove:(int)tag toTag:(int)tag2
{
//取要移动到的位置button
UIButton *mybutton = (UIButton *)[self.view viewWithTag:tag2];
//取点击的button
UIButton *mybutton1 = (UIButton *)[self.view viewWithTag:tag];
//点击button的图片
UIImage *myImage = mybutton1.currentBackgroundImage;
//把图片赋值给空的button
[mybutton setBackgroundImage:myImage forState:normal];
//原先有图片的button背景图片赋值为空
[mybutton1 setBackgroundImage:nil forState:normal];
}
原文地址:http://blog.csdn.net/u010438187/article/details/45627123