活动指示器动态改变颜色ios swift [关闭]

问题描述 投票:-7回答:1

帮助我解决问题或任何可用于活动指标的第三方。

在得到结果后,活动指示器改变颜色

有没有人这样做过?

ios swift uiactivityindicatorview
1个回答
2
投票

下次请按照Desdenova的评论中的建议。除此之外,你可以简单地改变colorUIActivityIndicatorView属性。

这是一个简单的游乐场代码片段,它会在2秒后更改颜色。

import UIKit
import PlaygroundSupport

class ViewController: UIViewController{
    override func viewDidLoad() {
        super.viewDidLoad()

        view.backgroundColor = .white

        let activityIndicator = UIActivityIndicatorView(frame: CGRect(x: 50, y: 50, width: 100, height: 100))
        activityIndicator.style = .whiteLarge
        activityIndicator.color = .red

        view.addSubview(activityIndicator)

        activityIndicator.startAnimating()
        DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(2)) {
            activityIndicator.color = .blue
        }
    }
}

let viewController = ViewController()
viewController.preferredContentSize = CGSize(width: 375, height: 667)
PlaygroundPage.current.liveView = viewController

最好,卡斯滕

© www.soinside.com 2019 - 2024. All rights reserved.