Activity Indicator 추가하기
private lazy var activityIndicator: UIActivityIndicatorView = {
let activityIndicator = UIActivityIndicatorView()
activityIndicator.frame = CGRect(x: 0, y: 0, width: 50, height: 50)
activityIndicator.center = CGPoint(x: self.view.center.x, y: self.view.center.y - self.topbarHeight)
activityIndicator.hidesWhenStopped = false
activityIndicator.style = UIActivityIndicatorView.Style.medium
activityIndicator.startAnimating()
return activityIndicator
}()
떼고, 붙이는 함수도 만들어주고
private func attachActivityIndicator() {
backgroundView.backgroundColor = UIColor.white
self.view.addSubview(backgroundView)
self.view.addSubview(self.activityIndicator)
}
private func detachActivityIndicator() {
if self.activityIndicator.isAnimating {
self.activityIndicator.stopAnimating()
}
self.backgroundView.removeFromSuperview()
self.activityIndicator.removeFromSuperview()
}
통신 시작할때 붙이고
통신 끝나고 호출되는 함수에서 떼주면 완성!