关于 swift:UIActivityIndi??catorView 未显示在 iOS UIViewController 中 | 珊瑚贝

UIActivityIndicatorView not showing up in iOS UIViewController


我想在视图中心的视图控制器中显示一个灰色的 UIViewIndicatorView,但是这段代码没有显示任何内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class MyViewController: UIViewController {
    var activityIndicatorView = UIActivityIndicatorView()

    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .black
        displayActivityIndicator()
    }

    func displayActivityIndicator() {
        view.addSubview(activityIndicatorView)
        activityIndicatorView.style = .gray
        activityIndicatorView.translatesAutoresizingMaskIntoConstraints = false
        activityIndicatorView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
        activityIndicatorView.widthAnchor.constraint(equalToConstant: 40).isActive = true
        activityIndicatorView.heightAnchor.constraint(equalToConstant: 40).isActive = true
        activityIndicatorView.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
        activityIndicatorView.startAnimating()
    }  
}

仅当我将视图控制器的视图设置为类似白色(不包括黑色)的颜色时,才会显示活动指示器视图。

我怎样才能让它显示出来?


改变背景为

1
view.backgroundColor = .green // for example

1
activityIndicatorView.style = .white

然后你会看到它,因为它几乎是指示器和背景视图之间的颜色匹配

  • 我希望视图的背景颜色为黑色。
  • 灰色离黑色很近
  • 我的意思是纺车应该是白色的或其他的。
  • 视图背景颜色应严格为黑色。


来源:https://www.codenong.com/53988562/

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_9819.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?