按钮背景颜色在uicollectionview单元格中重复

时间:2016-08-22 11:45:07

标签: uibutton uicollectionviewcell background-color

我的单元格上有一个类似的按钮(已连接到CustomCVCell.h文件),我需要在按下时更改此按钮的背景。为此,我编写了此代码。

Collectionviewcell.h

  • (IBAction为)secondlikebuttn:(ID)发送者;

在collectionviewcell.m

  - (IBAction)secondlikebuttn:(id)sender {

UIButton *buttonObj = (UIButton*)sender;

[buttonObj setBackgroundImage:[UIImage imageNamed:@"like_icon_inst1_red"]
                              forState:UIControlStateNormal];

_commview.hidden=YES;
_shareview.hidden=YES;
_likeview.hidden=NO;

}   当单击按钮时,所选idexpath上按钮的背景图像正在改变,但问题是它也反映了其他索引路径中的更改。

enter image description here

感谢您快速回复。

0 个答案:

没有答案