Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 170 Vote(s) - 3.39 Average
  • 1
  • 2
  • 3
  • 4
  • 5
'imageEdgeInsets' was deprecated in iOS 15.0

#1
I'm getting the warning:

'imageEdgeInsets' was deprecated in iOS 15.0
When setting UIButton imageEdgeInsets like so:

button.imageEdgeInsets = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)

I tried setting imageEdgeInsets like so:

UIImage(named: "filter")?.withRenderingMode(.alwaysTemplate).withAlignmentRectInsets(UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10))
Both where top, left, right and bottom are positive or negative values, no luck. Anyone who knows the version of

imageEdgeInsets
That's not deprecated in iOS 15?
All help is appreciated,
Kind regards :)
Reply

#2
Swift now comes default with different types of buttons that you can setup up from iOS 15 onwards. Use `UIButton.Configuration` to set up your button. For your case, you can use,

```Swift
config.imagePadding = 5
```
An example can be seen below:

```Swift

var filled = UIButton.Configuration.filled()
filled.title = "Filled button"
filled.buttonSize = .large
filled.subtitle = "With subtitle even"
filled.image = UIImage(systemName: "bubble.left.fill")
filled.imagePlacement = .trailing
filled.imagePadding = 5

let button = UIButton(configuration: filled, primaryAction: nil)
```
[![enter image description here][1]][1]


[1]:


Image and Code credits to [nemecek.be](

[To see links please register here]

)
Reply

#3
iOS 15 Apple introduced 3 new options to control padding and insets.

1. ```.titlePadding``` : Padding between the title and subtitle labels.
2. ```.imagePadding``` : Padding between the button’s image and text.
3. ```.contentInsets```: Padding from the button’s content area to its bounds.

Using the above option you can manage and set your button style according.

[![enter image description here][1]][1]

You can check this [article][2] for more. [Source and Image][2]

So your code should be like this

```
var configuration = UIButton.Configuration.filled()
configuration.title = "Title"
configuration.image = UIImage(systemName: "swift")
configuration.titlePadding = 10
configuration.imagePadding = 10
configuration.contentInsets = NSDirectionalEdgeInsets(top: 10, leading: 10, bottom: 10, trailing: 10)
```


[1]:

[2]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through