Questions tagged [uibutton]
UIButton is a subclass of UIView for displaying buttons in iOS. It implements the target action paradigm to send events to the controller layer.
11,255
questions
0
votes
1
answer
32
views
How do I fix ImageEdgeInsets deprecated in iOS 15.0 when the padding needs to be different on each side?
So imageEdgeInsets has been depricated in iOS 15. Right now the code looks like this:
class MyButton: UIButton {
init(title: String) {
super.init(frame: .zero)
setTitle(...
-1
votes
0
answers
40
views
How to Resize the Image of a UIButton by Adding Contraints through View Editor?
I have been following this tutorial from Udacity and their solution to "Resizing the Stop Button" was to use the contextual menu to add height and width contraints.
Udacity's button image ...
0
votes
2
answers
49
views
UIButton frame size doesn't update to support increased font size from settings
I have a basic UIButton with the following constraints:
I have some basic trailing and top constraints and I have a >= width and height constraint set to 48 as I want 48 to be my minimum width and ...
0
votes
1
answer
30
views
Change title of array of UIButtons
i have an array of buttons and I try to change the name of the buttons but I don't know how to access to all buttons when the array randomPokemons get new data in the function didSet.
I can change the ...
0
votes
1
answer
16
views
Animation not working on touchesBegan button highlight
I'm trying to highlight buttons using a custom UIImageView layer on top of the buttons, invoking touchesBegan, but its not animating.
It's working perfectly except I can't seem to get it to animate ...
-1
votes
0
answers
13
views
Diferent sizes in viewDidAppear and viewDidLayoutSubviews
I'm changing the sizes of two buttons in the viewDidLayoutSubviews and they have the same size but when I try the aplication the size had changed, I printed the sizes in the viewDidLayoutSubViews and ...
-1
votes
2
answers
51
views
How to use a string in a function name
I have these functions:
private func chooseOfferButton1Tapped() {
let vc = ChooseRdvVC()
vc.offerCatched = arrayCatched![0]
HapticsManager.shared.vibrate(for: .success)
...
0
votes
1
answer
91
views
How to have UIButton image using UIButton.Configuration adapt and resize dynamically to the button size
I would like to use UIButton.Configuration to create and configure UIKit buttons in the app.
I cannot have the image in the button resizing accordingly to the size of the button itself leading to an ...
0
votes
0
answers
25
views
UIButton greys out when another View Controller is presented modally
I have a few buttons in a View Controller. One of them performs a segue to another View Controller. When this happens, all buttons change tint color to grey. When VC is dismissed, everything comes ...
0
votes
1
answer
24
views
Updating Button Title w/ Boolean Variable Swift
I'm trying to figure out how to properly configure a follow/unfollow button in a similar fashion to Instagram.
First I've created an IBOutlet for the button and used didSet to define its properties:
@...
0
votes
0
answers
62
views
How to add shadow on buttons with new UIButton Configuration way?
I am trying to refactor buttons in the app. Previously, shadows on buttons could be implemented easily using layer.shadowColor and similar properties. However, with the new Configuration style, I am ...
0
votes
0
answers
47
views
How can I avoid the titleEdgeInsets' was deprecated warning / Swift
I'm trying to make the warning 'titleEdgeInsets' was deprecated in iOS 15.0: This property is ignored when using UIButtonConfiguration disappear.
At first, I used
InfosButton.titleEdgeInsets.top = ...
0
votes
1
answer
57
views
How to change position of image of UIButton in Swift
I'm trying to bring up the image of my UIButton of a few pixels, does anyone knows how to do it? I tried with ContentEdgeInset but it doesn't seem to work.
0
votes
3
answers
79
views
Is there a way to save 'selected' state of a UIButton?
I'm creating a jigsaw puzzle app for kids with 24 different little puzzles in 24 different scenes. I've put the background music in a Singleton, like so:
class MusicHelper { static let sharedHelper = ...
1
vote
1
answer
65
views
How to get attribute from AttributeContainer in UIKit and assign it to some variable
I create next subclass:
import UIKit
class Button: UIButton {
override func updateConfiguration() {
var config = configuration ?? UIButton.Configuration.plain()
let color = ...
0
votes
1
answer
60
views
SWIFT & Storyboard - Tableview with Sections and each them contains a list of checkboxes
Goodmornig, i need a little help for showing the tableview with sections and custom tableviewcell for each section. I would want achieve this goal as image below:
From picture we understand there ...
0
votes
2
answers
58
views
UIButton and TextEdit inside of UIView inside of UIScroll View
I've got a UIButton and a couple of TextEdit's in a UIView. UIView itself is in a UIScrollView. Somehow UIButton can not be pressed in the structure I mentioned. Look at the following code:
...
1
vote
2
answers
73
views
Strange UIView.animate behavior changing UIButton title color
Question
I am trying to animate a UIView color from light grey to dark grey and a UIButton title color from blue to orange.
The animation is meant to take place over 3 seconds when the UIButton is ...
1
vote
0
answers
33
views
UIButton with an external website link but it is not responding to touches
I added a UIButton with an external website link but it is not responding to touches.
@IBAction func onHavaDurumuHaberleriBtn(_ sender: Any) { UIApplication.shared.open(URL(string:"https://www....
0
votes
0
answers
28
views
I am trying to add size constraints to a button in Xcode 14. It appears that the constraints have been added but I see no physical change
Screenshot from Xcode
(I am using a tutorial from Udacity that was made in 2016, so the Xcode is different. I have followed the steps in the tutorial but I am not getting the same result).
I have ...
-1
votes
1
answer
91
views
Problem with UIKit button with left aligned text and right aligned image
I wanted to create a dropdown button with the text on the left and the icon all the way to the right and I haven't found a clean way of doing this either with iOS 15's UIButton.Configuration or the ...
1
vote
0
answers
96
views
How to add and remove to favourites view on heart button press in swiftui
I have a struct and I displayed the product list screen from that struct.There is a heart button in product list view, I want to add the particular item to favourite view on button press and also ...
-1
votes
2
answers
45
views
How to check multiple textfields are nil or not and enable button accordingly in swift
I need to enable nextBtn when all textfields has some text only
tried below code: but with this code when i tap on first textfield then my nextBtn becomes enabled why? how to make nextBtn enable after ...
0
votes
1
answer
23
views
iOS: Appending UIButton right next to multilines UILabel
I am trying to make UILabel with UIButton (more Info) that appends right next to uilabel in multi-lines UILabel.
As shown in the picture (case 1, 2), if uilabel text is short, and doesn’t exceed ...
0
votes
0
answers
35
views
iOS 15 UIButton configuration - How to place imageview on the top left
In iOS 15 we now have a new way to configure a UIButton via UIButton.Configuration struct.
I'm trying to obtain a button with the following layout:
but I can't find a way to place the image view on ...
-1
votes
2
answers
85
views
UIStackView does not respect size of programmatically added buttons
I have a UIStackView that includes either three or four custom UIButtons. All buttons are completely rounded, the left and right buttons are slightly bigger than the center one/two. Somehow, I can't ...
0
votes
0
answers
26
views
iOS UIButton subclass setTitle forState not called from storyboard
I have a CustomButton: UIButton that overrides setTitle:forState: and setAttributedTitle:forState:.
When I use this button in a storyboard file and set the text via storyboard, neither setTitle or ...
0
votes
2
answers
330
views
How to implement a pull-down button that supports multiple selection?
I had no trouble implementing a pop-up button that lets a user select from a mutually exclusive list of options. This is covered in the Pop-up buttons section of the HIG.
Now I want something similar ...
0
votes
1
answer
27
views
Why is my animation of my UIButton in swift faded/transparent when getting highlighted?
I'm animating my custom view of an UIBarButtonItem by rotating it by 45° (+ -> x). But my + image is fading when highlighted. When it isn't highlighted anymore it animates back (x -> +) and ...
-2
votes
1
answer
33
views
Flutter Colored Radio Button
in flutter How do I make this type of Colored Radio button?
-1
votes
1
answer
27
views
Having issues getting the setTitle function to work with nextButton
After running the code, everything works except for the setTitle command that would change the text inside the button. I've tried everything and even copied tutorials, but no luck. I started Swift 2 ...
-1
votes
1
answer
51
views
UIButton doesn't change its size based on the length of the text
If I change the type to plain, everything works, but it's not a good button type for what I need to do. If I keep it the default type the text pops out and the button stays the same size. Do you have ...
0
votes
1
answer
189
views
SwiftUI - Make entire width of a button in a section clickable, not just text
I am trying to make a Log Out button inside a List with sections. However, when I add the button to the section, only the "Log Out" text is clickable and not the entire section. I don't want ...
0
votes
1
answer
68
views
Create an expanding horizontal UIStackView with selectable buttons in two states in UIKit
I want to create a horizontal UIStackView containing 5 buttons. Each button can be in one of two states: selected or unselected. When a button is unselected, it appears as a square containing only an ...
0
votes
0
answers
20
views
How do I change a "NavigationLink" so it appears onscreen as a button?
I am currently working on my first "project". I have built an app for work, and although the core concepts are in place (which I'm very proud of!) I'm now trying to make it look a little ...
2
votes
0
answers
113
views
Focus state styling of UIButtons ignored when using UIButton.Configuration on tvOS
When using UIButton.Configuration to style UIButtons depending on their state, everything works as expected on iOS.
However, on tvOS the button configuration's baseBackgroundColor, baseForegroundColor,...
0
votes
1
answer
37
views
How do I use Touch Up Inside for several buttons?
I am trying to make a label's text change to different text based on the buttons pressed. For example, if btn_1 is pressed label_1 will show some text, and when btn_2 is pressed, it'll show something ...
0
votes
1
answer
122
views
UIStack of UIButton dynamic size / height according to title
I have UITableview with custom cells. In each cell I have on one side a vertical UIStack view of UIButtons. The number of the buttons per stack varies per cell.
As part of the code for the cell I ...
1
vote
1
answer
123
views
UIButton.configuration in Swift and Objective-C
I noticed, that configuration property of UIButton is implemented(?) differently in Swift and Objective-C.
In UIButton header configuration is of UIButtonConfiguration type which is a class.
@property ...
-1
votes
2
answers
171
views
UIAction calling multiple times when tapped on UIButton in CollectionViewCell
When I tap on button it will trigger multiple times.
CollectionViewCell file code
class PhotoCell: UICollectionViewCell {
@IBOutlet weak var deleteButton: UIButton!
}
ViewController - ...
-1
votes
1
answer
42
views
Blogger button link change after clicking it
In blogger, if the user click the button, it redirect to desired link. If the user click the same button for second time, I want to make the button to be redirected to another link. So how can I ...
1
vote
1
answer
52
views
I'm having trouble moving items from one array to another through a button
So I'm new to swift and I'm having trouble making my wishlist button move one item from the array sneakers to the array sneakers1
class Sneakers {
var sneakers = [
BagProducts(image: ...
0
votes
0
answers
23
views
UIButton appearance font not working for UIButtonLabel
I set a default UIButton Font.
UIButton.appearance().titleLabel?.font = UIFont.systemFont(ofSize: 17)
But It not working for UIButton Style Default. It's titleLabel is not UILabel , It's a private ...
0
votes
0
answers
4
views
having issues with my app any time i click any of the button it crashes with an error message the button is suppose to send me to another page
having issues with my app any time i click any of the button it crashes with an error message the button is suppose to send me to another page but it keeps showing error have tried different ways of ...
-1
votes
1
answer
34
views
Swift, UIButton's image disappeared
Swift application, Xcode 14.2. Target 16.2. I have UIButton in my storyboard with properties "Type: Custom, Style: Default". If I set an image from .xcassets file, on preview everything ok, ...
0
votes
2
answers
271
views
setTitleColor not working for custom UIButton in .disabled state
I have a form to collect basic user info. There is a "Continue" button on the form that has different appearances based on whether it is in the .enabled or .disabled state.
The .enabled ...
0
votes
1
answer
155
views
UIButton title expansion limits [duplicate]
I'm having a trouble for controlling the title expansion limits of UIButton with the UIButtonConfiguration. Here is the setup code of my button:
private lazy var button: UIButton = {
let btn = ...
0
votes
1
answer
18
views
Swift use UIButton method for UIView
Here is my code, I try to go through all programmatically created buttons, and if I found the needed one, then change its background, but I don't know how to do it, because subview is the instance of ...
0
votes
0
answers
53
views
Move to Wishlist Button
So i'm new to swift and i'm have trouble making my wishlist button move the items from the array sneakers to the array sneakers1
class Sneakers {
var sneakers = [
BagProducts(image: ...
0
votes
1
answer
35
views
Can you add a UIButton be used as the UI for a SKSpriteNode?
I have UIButton that I created with custom UI properties and I want to add animations to it where it has a gravity and falls downwards using SpriteKit. Is it possible to SKSpriteNode support my ...