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:
  • 671 Vote(s) - 3.51 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to round the corners of a button

#11
For iOS SWift 4

button.layer.cornerRadius = 25;
button.layer.masksToBounds = true;
Reply

#12
First set width=100 and Height=100 of button

> Objective C Solution

YourBtn1.layer.cornerRadius=YourBtn1.Frame.size.width/2;
YourBtn1.layer.borderColor=[uicolor blackColor].CGColor;
YourBtn1.layer.borderWidth=1.0f;

> Swift 4 Solution

YourBtn1.layer.cornerRadius = YourBtn1.Frame.size.width/2
YourBtn1.layer.borderColor = UIColor.black.cgColor
YourBtn1.layer.borderWidth = 1.0
Reply

#13
Try my code. Here you can set all properties of UIButton like text colour, background colour, corner radius, etc.

extension UIButton {
func btnCorner() {
layer.cornerRadius = 10
clipsToBounds = true
backgroundColor = .blue
}
}

Now call like this

yourBtnName.btnCorner()
Reply

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

For **Objective C**:

```
submitButton.layer.cornerRadius = 5;
submitButton.clipsToBounds = YES;
```
For **Swift**:
```
submitButton.layer.cornerRadius = 5
submitButton.clipsToBounds = true
```


[1]:
Reply

#15
I tried the following solution with the UITextArea and I expect this will work with UIButton as well.

First of all import this in your .m file -

#import <QuartzCore/QuartzCore.h>

and then in your `loadView` method add following lines

yourButton.layer.cornerRadius = 10; // this value vary as per your desire
yourButton.clipsToBounds = YES;

Reply

#16
You can use outlet connection and didSet function for your button on the view;

@IBOutlet weak var button: UIButton!{
didSet {
button.layer.cornerRadius = 5;
button.layer.masksToBounds = true;
}
}
Reply

#17
# Swift 4 Update #
I also tried many options still i wasn't able to get my UIButton round cornered.
I added the corner radius code inside the ```viewDidLayoutSubviews()``` Solved My issue.

```
func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
anyButton.layer.cornerRadius = anyButton.frame.height / 2
}
```

Also we can adjust the cornerRadius as follows:

```
func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
anyButton.layer.cornerRadius = 10 //Any suitable number as you prefer can be applied
}
```
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

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