Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make rounded corner progress bar in swift?

Tags:

Here I Have tried to make Rounded Rect corner progress bar but I have some problem to create it, here I have post my code what I am tried?

Any one Give idea to customize the progress bar to rounded rect corner progress bar.

self.progressView.frame=CGRectMake(55, 490, 200, 15) self.progressView.layer.cornerRadius = 15.0 self.progressView.transform=CGAffineTransformMakeScale(1.0, 7.0) 
like image 599
B.Saravana Kumar Avatar asked Aug 20 '15 09:08

B.Saravana Kumar


People also ask

How do you round the edges of a button in SwiftUI?

You can round the corners of any SwiftUI view by using the cornerRadius() modifier. Simply add a value to the cornerRadius to control how rounded you want the view to be. Let us look at a simple example below. By adding a cornerRadius of 10 to our button we now get nice rounded corners on our button.

How does swift implement progress bar?

Select the LoadingView in the storyboard, and open the Attributes inspector. For the background Background, select System Gray 4 Color. Next, you'll add the progress bar.


2 Answers

Although you have set the corner radius, you also need to tell the view not to draw anything outside of the view's bounds by setting

self.progressView.clipsToBounds = true 
like image 121
Swinny89 Avatar answered Sep 24 '22 03:09

Swinny89


And if you want to have rounded edges for the inner bar too, you can also add this code:

// Set the rounded edge for the outer bar self.layer.cornerRadius = 12 self.clipsToBounds = true  // Set the rounded edge for the inner bar         self.layer.sublayers![1].cornerRadius = 12 self.subviews[1].clipsToBounds = true 
like image 40
Andrea Miotto Avatar answered Sep 23 '22 03:09

Andrea Miotto