1

I have two button say button1 and button2 declared as

- (IBAction)button1:(id)sender;
  @property (strong, nonatomic) IBOutlet UIButton *button2;

What I want to do is, when button1 is click button 2's tint color should be changed, so its like both button1 and 2 are same, when I click on button1 the tint should also effect in button2 as if button2 is also clicked, so its appearance should be like clicking two buttons at once when I click on button1. Is this possible?

My UserInteraction for button2 is disabled as I dont need its click event. On my button1 click I need button2 to also tint giving it an appearance like button 1 and 2 are simultaneously clicked.

EDIT: Some of you guys are still not getting my point. Imagine that on the run time screen there are two buttons, Button1 and Button2, imagine Button1 is invisible. Now if I click on Button1 it should look on the screen that I just clicked Button2. Setting tint color will only set the button2 tintcolor but it will not give the button clicked effect.

4

3 回答 3

0

是的,您所要做的就是将按钮连接到插座......您可以随心所欲地给它们打电话。将此代码放入您的IBActions中。

   your1stButton.tintColor = [UIColor redColor];
   your2ndButton.tintColor = [UIColor redColor];

your1stButton在不同的动作中更改颜色并确保更改your2ndButton为您的网点名称。

于 2013-09-06T12:33:06.490 回答
0

您需要在标题中将 button1 和 button2 设置为@property(出口),并声明方法。在该- (IBAction)button1:(id)sender;方法中,您可以像这样设置色调颜色:self.button2.tintColor = [UIColor redColor];

- (IBAction)button1:(id)sender
{
  self.button2.tintColor = [UIColor redColor];
}

- (IBAction)button2:(id)sender
{
  self.button1.tintColor = [UIColor redColor];
}
于 2013-09-06T12:33:37.910 回答
0
- (IBAction)button1:(id)sender;
{
   btn1.tintColor = [UIColor redColor];
   btn2.tintColor = [UIColor redColor];


}
- (IBAction)button2:(id)sender;
{

btn1.tintColor = [UIColor redColor];
   btn2.tintColor = [UIColor redColor];


}
于 2013-09-06T12:34:38.237 回答