0

I'm working on an Ipad application, and i need to set a title on a 'UIButton', in order to could use :

-(void)MyMethod:(id)sender
{
    UIButton *resultButton = (UIButton *)sender;
    if ([resultButton.currentTitle isEqualToString:@"TitleName"])
    {
        ...
    }
}

But when I use this sort of code :

[MyUibutton setTitle:@"TitleName" forState:UIControlStateNormal];

It appears "TitleName" behind the image of the 'UIButton'...

So, is it possible to fix it ?

Thanks !

4

4 に答える 4

4

ボタンのタイトルは使用しないでください。フラグではなく表示用です。代わりに、tagまたはobjc_setAssociatedObjectボタンを辞書に保存して比較します。

于 2013-09-14T22:00:11.133 に答える
2

theButton.titleLabel.alpha = 0;

于 2013-09-14T23:32:14.563 に答える
0

ボタンの画像を設定すると、ボタンの上部に配置されるため、ボタンのタイトルは表示されません。ボタンの背景を設定すると、問題が解決します!

[yourbutton setBackgroundImage:YOURIMAGE forState:UIControlStateNormal];
于 2013-09-14T22:06:18.593 に答える