【发布时间】:2015-03-17 22:42:31
【问题描述】:
我通过创建渐变层创建了要在 tableView 中使用的进度条。它完美地工作。
iPhone5:
为了在多个设备上使用该应用程序,我在 Storyboard 中创建了 UIView,对其进行了标记并添加了约束。 但是,当我在 iPhone 6 上使用该应用程序时,CALayer 不会调整大小。
iPhone6:
我觉得这非常愚蠢,但没关系。几个月来,我环顾四周,试图了解如何解决这个问题,但我做不到。 ANYONE 知道如何使用 UIView 调整 CALayers 的大小吗?任何帮助将不胜感激!谢谢。
progressBar = cell.contentView.viewWithTag(3) as UIView!
progressBar.layer.cornerRadius = 4
progressBar.layer.masksToBounds = true
// create gradient layer
let gradient : CAGradientLayer = CAGradientLayer()
// create color array
let arrayColors: [AnyObject] = [
UIColor (red: 255/255, green: 138/255, blue: 1/255, alpha: 1).CGColor,
UIColor (red: 110/255, green: 110/255, blue: 118/255, alpha: 1).CGColor]
// set gradient frame bounds to match progressBar bounds
gradient.frame = progressBar.bounds
// set gradient's color array
gradient.colors = arrayColors
//Set progress(progressBar)
var percentageCompleted = 0.6
gradient.startPoint = CGPoint(x: 0.0, y: 0.5)
gradient.locations = [percentageCompleted, percentageCompleted]
gradient.endPoint = CGPoint(x: 1, y: 0.5)
// replace base layer with gradient layer
progressBar.layer.insertSublayer(gradient, atIndex: 0)
【问题讨论】:
标签: ios