[英]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()
Welcome to Stack Overflow!欢迎使用堆栈溢出!
In answer to your question: you should set the CALayer
property cornerRadius
to a positive, non-zero value.回答您的问题:您应该将
CALayer
属性cornerRadius
设置为正的非零值。 For example:例如:
activityIndicator.layer.cornerRadius = 10
And the result:结果:
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.此外,由于您对编程完全陌生,我建议您查看 Apple 的The Swift Programming Language ,它是免费的,可带您了解整个 Swift 语言。 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)
这是链接: https : //itunes.apple.com/gb/book/swift-programming-language/id881256329?mt=11 (它也可以作为网络版本使用)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.