我怎样才能从标签中获取对象?

时间:2021-03-24 19:36:30

i have one view .in that view i have 2 buttons .

我有一个视图。在那个视图中我有2个按钮。

i know tag of that button . i want to change image of that button.

我知道那个按钮的标签。我想改变那个按钮的图像。

how can i change image by this tag?

如何通过此标签更改图像?

2 个解决方案

#1


21  

UIButton *button = (UIButton *)[myView viewWithTag:myTag];
[button setImage:... forState:...];

#2


0  

UIScrollView * scView=(UIScrollView*)[self.view viewWithTag:20];
UIButton *button = (UIButton *)[scView viewWithTag:3];

#1


21  

UIButton *button = (UIButton *)[myView viewWithTag:myTag];
[button setImage:... forState:...];

#2


0  

UIScrollView * scView=(UIScrollView*)[self.view viewWithTag:20];
UIButton *button = (UIButton *)[scView viewWithTag:3];