一次隐藏/显示多个按钮的标题

时间:2015-06-08 10:39:07

标签: ios button hide title

我有一个xib自动布局。我试图通过使用其中一个滑动椭圆开关来制作一组按钮来显示/隐藏他们的标题。

我把按钮放在一个数组中。然后试图打开和关闭按钮标题。这是迄今为止的代码。不工作。新手非常感谢!

// buttons array 
self.myButtonCollection = [[NSArray alloc]initWithObjects:self.D1Outlet,self.SlapOutlet,self.G7Outlet,self.A8Outlet,self.Bb3Outlet,self.D1Outlet,self.A2Outlet,self.F6Outlet,self.C4Outlet,self.D5Outlet,nil];

//Here is the switch notes code:

- (IBAction)switchNotes:(id)sender
{
    if([sender isOn])
    {
        NSLog(@"Switch is ON"); 
        for(UIButton *myButton in self.myButtonCollection)
        {
            [myButton setTitleColor:[UIColor clearColor] forState:UIControlStateNormal];
            [myButton setAlpha:0.0f];
        }
    }
    else
    {
        NSLog(@"Switch is OFF");
        for(UIButton *myButton in self.myButtonCollection)
        {
            [myButton setTitleColor:[BT_color getColorFromHexString:@"#000000"] forState:UIControlStateNormal];
            [myButton setAlpha:1.0f];
        }
    }
}

0 个答案:

没有答案