我正在尝试旋转在(在情节提要板上创建的)UIView下的UILabel,但是当我尝试CGAffineTransform(rotationAngle:)时,由于nil值导致应用程序崩溃。
是因为我使用情节提要引起的吗?
@IBDesignable
class AnalogView: UIView {
@IBOutlet var prevPitch:UILabel!
@IBOutlet var currectPitch:UILabel!
@IBOutlet var nextPitch:UILabel!
fileprivate let thickHorizontalLayer = CAShapeLayer()
fileprivate let thinHorizontalLayer = CAShapeLayer()
fileprivate let roundThinLayer = CAShapeLayer(layer: self)
fileprivate let roundThickLayer = CAShapeLayer(layer: self)
@IBInspectable var thickYCoord: CGFloat = 50.0
@IBInspectable var thinYCoord: CGFloat = 52.5
@IBInspectable var counterColor: UIColor = UIColor.orange
override init(frame: CGRect = .zero) {
super.init(frame: frame)
configure()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
private func configure() {
prevPitch.transform = CGAffineTransform(rotationAngle: 3.14)
最佳答案
您的标签prevPitch
未连接到情节提要项
在代码的左侧边栏中有一个加号而不是一个圆圈。
您应该重新连接它。也许在重命名时您失去了此连接
关于ios - 旋转UIView下的UILabel,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42959660/