iPhone toggle button implementation

前端 未结 7 2106
孤独总比滥情好
孤独总比滥情好 2021-02-04 09:05

I would like to create a toggle button in my iPhone application. However, I don\'t know exactly what would be the best approach for this.

I am considering two options.

7条回答
  •  忘掉有多难
    2021-02-04 09:13

    Just make an (IBAction) method and also a BOOL. Set the BOOL default to FALSE. Your IBAction must look like this:

    - (IBAction) .... {
    
        if (bool) {
            // do your things
        }
    
        else {
            // do your things
        }
    
        bool =! bool
    }
    

    That works for me!

提交回复
热议问题