Xcode 13 - Button title not disappearing
I found a solution - need to choose Default style.
UIButton title Button is not cleared after removing it from the attribute inspector
Change the button style from plain to default.
SWIFT: Button Title changing back to original title unwarranted
Change
createAccountOrLogInButton.titleLabel?.text = "Log In"
to
createAccountOrLogInButton.setTitle("Log In",for:.normal)
same for the first if
also
UIButton's title not setting to empty or a blank in iphone
you are resetting the title but after your title will ripopolate.
try
if (monthText>totalnumber) {
//...yourcode...
return;
}
let me know
UIButton title disappears
Well it's hard to say for sure, but is the text not visible because the color is the same? I see you set the text for all states but you may want to set the color for all states as well.
[commit setTextColor:[UIColor redColor] forState:UIControlStateSelected];
Custom UIButton - part of title disappears after click
changing Style of the button from Plain to Default was solution for the problem
UIButton title set in Storyboard is missing when run
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.
iOS - Interface Builder: UIButton title disappears when setting image
Change your button to custom type. put the image on then put the text in.
You will need to put your own background on it, but at that point you will be able to use the edge settings to position both the text and the image.
Every button that I have with image and text is set to custom and ultimately has its own bg image as well.
Oh, another thing I use. Is the cornerRadius. To give the view the rounded effect like the buttons have by default.
saveButton.layer.cornerRadius = roundingNumber.floatValue;
Additionally you should be able to use the borderWidth and borderColor in conjunction with cornerRadius to get a button that looks quite similar to the original button
saveButton.layer.borderRadius = 1.0f;
saveButton.layer.borderColor = [[UIColor blueColor] CGColor];
// These are not the exact values (or maybe they are) but you get the idea.
hope that helps.
Correction
After Spending a little time investigating, it appears that when you put an image in the button. the text is shoved off to the right.
Use the edge settings to bring it back over the image.
With the button selected, Look in "Attributes Inspector" > Button > Edge > (Dropdown "Title")
the equasion I have come up with is
[Edge inset for Title] Left = -(imageWidth * 2)
This should Left align your title with the image that you have put in.
Custom positioning will need to be done to make it look correct.
This can be done entirely in the Interface Builder and you can use RoundedRect button style
Here are some images demonstrating the change.
Here I set the Button type to "Custom" to remove the border and background.
Here I set the Top and Left in the Edge set for "Title" (Title is an option in the drop down)
EDIT
Newest Xcode has moved the size settings to a new location
ios14 - Button Title and Image Not getting Displayed
Xcode 12.0.1, iOS 14, Swift 5.3
Actually the problem was in the redundant code which was lying around in my codebase.
extension UIButton {
open override func layoutSubviews() {
super.layoutSubviews()
}
}
I just had this sitting in my extensions. This didnt cause any issues in iOS 13 and below.
Steps to reproduce:
- Add above code in your project.
- Run the project(Release or Debug Mode) the project in your simulator(Button renders properly) and Kill the app.
- Now, Launch the app by clicking App icon and you will see Button contents disappear.
Strange bug, i hope it save someones time.
Related Topics
How to Upload Multiple Images in Multipart Using Alamofire
How to Make Inputaccessoryview Appear Above Uitabbarviewcontroller's Tabs
Are Private Frameworks Supported on iOS
Value of Type 'string' Has No Member 'stringbytrimmingcharactersinset'
Ckfetchnotificationchangesoperation Sometimes Does Not Return Update, Delete Notifications
View Height Problems (Continued)
iOS 13.2 Message: Nehelper Sent Invalid Result Code [1] for Wi-Fi Information Request
Why Is Optional("Text") - Swift
iOS Lazy Var Uibarbuttonitem Target Issue
Screenshot on Swift Programmatically
How to Call Objective-C Instancetype Method in Swift
How to Figure Out When a HTML5 Video Player Enters The Full Screen Mode on iOS/Ipads
Using Shader Modifiers to Animate Texture in Scenekit Leads to Jittery Textures Over Time
How to Programmatically Delete My Own iOS App
Mkannotation Not Getting Selected in iOS5
Contentview with UItableview Not Scrolling Within UIscrollview