1
votes

I would like to remove the selected state effect from the UIButtons.

When pressed a blue capsule appears next to the UIButton.

UIButton-selected-state

UPDATE with new problem

UIButton with type:system selects the targeted button. After changing the UIButton type to custom. This effect was removed. Other buttons were pressed that are located in the same view.

This is part of the UIButton function, if pressed it should run the code in this IBAction. Two UIButtons are connected to this function. With type system it selected the right UIButton, with type custom it seems to select at random.

  - (IBAction) buttonAction:(id)sender
      {
         UIButton *btn = sender;

         btn.selected = !btn.selected; 

         if([sender tag] == 1){
            // run code UIButton 1
         }

         if([sender tag] == 2){

            // run code UIButton 2

         }
    }

I hope this is clear.

2
Thank you for entering the image - Mohamed El Kawakibi
Change the button's type as custom - RajeshKumar R
@RajeshKumarR How can I do that? - Mohamed El Kawakibi
Have you created these buttons in storyboard? - RajeshKumar R
No, a made a new xib file with a view. - Mohamed El Kawakibi

2 Answers

0
votes

Select the button from the xib file and change its type to custom in attributes inspector.

enter image description here

0
votes

I found the solution to the second problem I described.

The UIButton type: custom doesn't have the selected trait as default. The traits that were selected are: Button and User Interaction Enabled. After selecting: selected it worked.

traits