2017-04-14 97 views
-1

我正在開發一個類似於我公司的蘋果appstore的企業應用程序。在這我有一個要求實現循環下載進度圖像相同,當我們從appstore下載或更新任何應用程序時出現的圖像。這怎麼可以用Swift語言實現。 任何建議將是真正有用的..蘋果設備安裝移動應用程序的進度圈

欲瞭解更多信息PLZ對此enter image description here

+1

你可以找到來自cocoascontrol.Use此鏈接以供參考https://github.com/mrackwitz/MRProgress和https://github.com/PavelKatunin/DownloadButton –

+0

非常感謝你的朋友:) – victorious

+0

: - 很高興我能幫助ü。 –

回答

0
`JPCActivityIndicatorButton` is working fine in `Xcode 8.3` `swift 3.x` 

有用的情況下,一起來看看 - >

case Names.Spinning: 
     activityIndicator.transitionSavedState(Names.ProgressBar) 
    case Names.ProgressBar: 
       activityIndicator.transitionSavedState(Names.Paused) 

dont't forget to add framework to your project

代碼詳細JPActivityIndicatorButton

0

我正在研究類似的任務,並且今天就設法實現了這一點。我認爲最簡單的方法是增強當前的用戶界面,這樣你只需要處理與進度圈相關的部分。

就我而言,我創建了一個名爲「UIButtonEnhanced」的新類,它是UIButton的一個子類。

請注意,在您的界面生成器中,您應該先將按鈕的類更改爲「UIButtonEnhanced」,然後創建出口。

enum DownloadStatus { 
    case remote 
    case downloading 
    case paused 
    case resumed 
    case success 
} 
    // MARK: extension is not ideal, a better solution should be a subclass of UIButton 
class UIButtonEnhanced: UIButton { 
    var progress: Float = 0 { 
     didSet { 
      circleShape.strokeEnd = CGFloat(self.progress) 
     } 
    } 

    var circleShape = CAShapeLayer() 
    public func drawCircle() { 
     let x: CGFloat = 0.0 
     let y: CGFloat = 0.0 
     let circlePath = UIBezierPath(roundedRect: CGRect(x: x, y: y, width: self.frame.height, height: self.frame.height), cornerRadius: self.frame.height/2).cgPath 
     circleShape.path = circlePath 
     circleShape.lineWidth = 3 
     circleShape.strokeColor = UIColor.white.cgColor 
     circleShape.strokeStart = 0 
     circleShape.strokeEnd = 0 
     circleShape.fillColor = UIColor.clear.cgColor 
     self.layer.addSublayer(circleShape) 
    } 

    // MARK: - Update the download status 
    var status: DownloadStatus = .remote { 
     didSet{ 
      var buttonImageName = "" 
      switch self.status { 
      case .remote: 
       buttonImageName = "DownloadButton" 
      case .downloading: 
       buttonImageName = "PauseButton" 
      case .success: 
       buttonImageName = "DeleteButton" 
      case .paused: 
       buttonImageName = "DownloadButton" 
      case .resumed: 
       buttonImageName = "PauseButton" 
      } 
      self.setImage(UIImage(named: buttonImageName), for: .normal) 
     } 
    } 
    } 

在你的viewController,您可以創建下面的代碼循環:

yourButton.drawCircle() 

那麼當你的下載進度的變化,使用此代碼:

yourButton.progress = 0.5 

當你的下載狀態修改,使用這個代碼:

yourButton.status = .success 
相關問題