UIButton not showing any effect when tapped? - ios

I am using Xcode 9.4.1 and I have added a UIButton in storyboard in a new project. Have changed the button to custom and have set constraints.
My problem is there is no change in button appearance when it is tapped. there has always been a default change in uibuttons appearance when it is tapped in earlier projects.
Is it only with me or its a general thing with new xcode?

You can try setting UIButton's selected state properties.

just check state of UIButton in Attributes Inspector set it enable then check type it should be system and not showing then once click on drawing = Show touch bar on Highlight then run your project and see when click is there any effect or not. Hope this is work fine for you.

Related

Why does UILabel looses it's highlighted state when it's set in story board?

I would like my UILabel to show it's highlighted state by default.
I've set a highlighted color and enabled the Highlighted property in my story board as shown in attached screenshot.
As expected, the story board shows my label in the desired state. But, when I run the app, the label is rendered in it's default text color.
Why is "isHighlighted" not set to true when I run the app?
Because this doesn't affect the app while running. The only usage is to let you see in IB the behavior when the state is selected. If you want to force the behavior at app launch use the following :
You can simply use UIButton as a highlighted text and do not pass any touchUpInside method. It will look like highlighted UILabel just by setting setSelected property on.

Program UIButton on swift

i have created a button on main.storyboard and i can add IBAction too. But, my aim is to make a sticky button(after you clicked once it is stayed pressed until you click it again) can somebody suggest please.
Set Image in selected state of uiButton,
means you need two image one for unselected and another for selected

How to make the buttons visible on simulator?

I'm using Xcode 5.1.1. I recently added a background image to my application but the buttons on the view controller aren't visible. When I remove the background image, the buttons become visible again. How to handle this?
If you are not checking the view hierarchy, then do one thing create outlet of you button and then write following code in viewDidLoad.
[self.view bringSubviewToFront:yourButton];
I don't know if you were used xib...
If you are using xib in your project, giving a background image for your button will more easy.
Place a button anywhere you want. Then go to attributes inspector on the right hand side. There you can find a field for changing your background image. Just give the name of your image.
Hope it will helpful for you

iOS: How to disable Fading in and out effect of UIButton

First of all, sorry for the title and asking this incredibly question but I simply couldn't figure it out. Also, since it is not related to code, I don't have code to show
I am working on an app and using iOS7 and I created a button from IB, set its background image to an image I designed. Connected it with header and set its touch up inside action as an IBAction
Yet, here is my problem. Whenever I click on the button, as an effect the image fades half transparent. I do not want this default attribute. I checked all the states on IB (highlighted, disabled, selected) and couldn't figure it out.
If I create the same button programmatically, only the text color changes, however when I set the background image, image fades (perhaps to indicate the button being pressed). How can I remove this effect?
A bit late but I believe this would solve the problem
in the xib file, set the button's type to Custom.
My button was set to system and when pressed on, it shows transparency and has a little fade in effect. Once I changed it to custom this effect is gone.
This cannot be changed once button is created. only in xib or when the button is first created.
have you tried this one yourButton.adjustsImageWhenHighlighted = NO?
If you set same background-image/background-color for every buttons states in IB (highlight, disable, selected) you will not get any fading in UIBUtton when you press it. You can set text color for every states also. If needed you can set different colors for every state and check the press action.
Hope the answered you expect. Thanks
Storyboard Solution
1:set button type to custom
2:uncheck "Highlighted adjusts Image"
If you want fading in & out effect your UIButton Type Should be a system, not custom.

UIButton title set in Storyboard is missing when run

I am quite new to iOS development and I encountered a problem when I was trying out a simple calculator tutorial. For some reason, the "0" and "=" does not appear on the iOS simulator while it appeared perfectly fine on the user interface shown on XCode.
Any idea on how to resolve this problem?
Thanks! =)
Just set the Style value to "Default" from "Attributes Inspector" tab as shown in the image below.
Now you should see the Font, Color and other attributed properties are back :)
In my case the button title disappeared, when I made changes to its attributes. Changing the Button title back to 'plain' and back again to 'attributed' made the text visible again.
One possibility could be that you accidentally set the titles of those two buttons on a control state other than default or UIControlStateNormal.
The buttons in your screenshot are in a state called UIControlStateNormal because they aren't being tapped or disabled. Select the buttons and make sure the 'State Config' option in the Attributes inspector is set to 'Default' when you're setting your title in Storyboard.
EDIT
Autolayout sometimes causes unintended behavior like this. If you aren't relying on Autolayout and don't plan to, you can turn it off in the File inspector. If you are relying on Autolayout, you'll have to write some code to undo the unintended behavior it's causing.

Resources