Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I round the corners of my Activity Indicator Background

I am BRAND NEW to coding. With that said, I have figured out how to put a grey background behind my white activity indicator spinner. Now I want the corners of the background to be rounded. I have searched and searched but I'm not having success.

Here is the code I am using to display the activity indicator and background. If you need more information to help, just ask. I don't really know how to even ask the question. I'm a total rookie.

activityIndicator = UIActivityIndicatorView(frame: CGRectMake(0, 0, 80, 80))

activityIndicator.center = self.view.center

activityIndicator.backgroundColor = (UIColor (white: 0.3, alpha: 0.8))   //create a background behind the spinner

activityIndicator.hidesWhenStopped = true

activityIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.WhiteLarge

view.addSubview(activityIndicator)

activityIndicator.startAnimating()

UIApplication.sharedApplication().beginIgnoringInteractionEvents()
like image 428
Greg Avatar asked Apr 07 '15 23:04

Greg


1 Answers

Welcome to Stack Overflow!

In answer to your question: you should set the CALayer property cornerRadius to a positive, non-zero value. For example:

activityIndicator.layer.cornerRadius = 10

And the result:

enter image description here

Also, since you're totally new to programming I would recommend you check out Apple's The Swift Programming Language, it's free and takes you through the whole Swift language. Here's the link: https://itunes.apple.com/gb/book/swift-programming-language/id881256329?mt=11 (It's also available just as a Web version)

like image 176
ABakerSmith Avatar answered Sep 18 '22 00:09

ABakerSmith