我正在开发一个类似于我公司的苹果appstore的企业应用程序。在这我有一个要求实现循环下载进度图像相同,当我们从appstore下载或更新任何应用程序时出现的图像。这怎么可以用Swift语言实现。 任何建议将是真正有用的..苹果设备安装移动应用程序的进度圈
-1
A
回答
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)
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
相关问题
- 1. 激活设备应用程序安装
- 2. 移动设备的Web应用程序?
- 3. WatchKit应用程序不安装在我的苹果手表
- 4. 安装后,应用程序将自动启动设备-iPhone
- 5. 安装Apple苹果MFI程序测试
- 6. 移动设备应用程序
- 7. 苹果手表应用程序被拒绝,因为应用程序没有安装在苹果手表上
- 8. iPhone应用程序与非苹果设备中的电路板进行通信
- 9. 无法安装苹果手表应用程序
- 10. 如何确保仅在设备上安装移动Web应用程序?
- 11. Android应用程序在真实设备上崩溃如果手动安装apk
- 12. 钛:检查设备上安装的应用程序(安卓)
- 13. 从智能设备应用程序关闭Windows移动设备
- 14. 苹果年度测试设备限制
- 15. 当在Windows移动设备上安装应用程序时,安装先决条件
- 16. 如何连接移动设备并在该设备中安装android应用程序?
- 17. 将应用程序安装为根系设备上的系统应用程序
- 18. 在应用程序的越狱设备上安装应用程序
- 19. 将应用程序安装在不同的设备上测试应用程序?
- 20. flipkart等应用程序如何检查设备中安装的应用程序
- 21. uri调用安装在设备中的应用程序
- 22. 更新安装在用户设备上的BlackBerry应用程序
- 23. 如何禁用设备管理员应用程序的安装?
- 24. 什么是苹果移动设备的操作系统
- 25. 无法我的设备上安装的应用程序 - 的iOS
- 26. 苹果设备上的Ajax
- 27. 安装在没有GPS的设备上的FINE_LOCATION应用程序?
- 28. 测试设备上的应用程序;安装的Xcode
- 29. 如何获取已安装应用程序的设备的deviceid?
- 30. 我的Android应用程序不能安装在我的设备
你可以找到来自cocoascontrol.Use此链接以供参考https://github.com/mrackwitz/MRProgress和https://github.com/PavelKatunin/DownloadButton –
非常感谢你的朋友:) – victorious
: - 很高兴我能帮助ü。 –