How to display an activity indicator with text on iOS 8 with Swift?

前端 未结 14 2163
没有蜡笔的小新
没有蜡笔的小新 2020-11-27 08:58

I wanna show, programmatically, an activity indicator with text, like the one in the Photos app (after editing and saving a picture). How can I do this?

14条回答
  •  清酒与你
    2020-11-27 09:37

    You can create your own. For example:

    Create a view with white background and rounded corners:

    var view = UIView(frame: CGRect(x: 0, y: 0, width: 300, height: 50))
    view.backgroundColor = UIColor.whiteColor()
    view.layer.cornerRadius = 10
    

    Add two subviews, a UIActivityIndicatorView and a UILabel:

    var wait = UIActivityIndicatorView(frame: CGRect(x: 0, y: 0, width: 50, height: 50))
    wait.color = UIColor.blackColor()
    wait.hidesWhenStopped = false
    
    
    var text = UILabel(frame: CGRect(x: 60, y: 0, width: 200, height: 50))
    text.text = "Processing..."
    
    view.addSubview(wait)
    view.addSubview(text)
    

提交回复
热议问题