import UIKit
class SalamView: UIView {
@IBOutlet var salamView: UIView!
@IBOutlet weak var salamLogoIMG: UIImageView!
var salamLogoImgOrigY: CGFloat!
var salamLogoImgFromToY: CGFloat!
override init(frame: CGRect) {
super.init(frame: frame)
initializeViews()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
initializeViews()
}
private func initializeViews(){
Bundle.main.loadNibNamed("SalamView", owner: self)
salamView.clipsToBounds = true
salamView.setHeight(height: screenSize.height - statusBarHeight)
salamView.setWidth(width: screenSize.width)
addSubview(salamView)
salamLogoImgOrigY = salamLogoIMG.frame.origin.y
salamLogoImgFromToY = -(salamLogoIMG.frame.size.height + salamLogoImgOrigY)
salamLogoIMG.frame = CGRect(x: salamLogoIMG.frame.origin.x,
y: salamLogoImgFromToY,
width: salamLogoIMG.frame.size.width,
height: salamLogoIMG.frame.size.height)
}
}
我需要将 salamLogoIMG 的 y 位置更改为 salamLogoImgFromToY,如果在 btn 操作中运行新的位置行代码它的工作,但我需要在第一次设置,请帮助我
最佳答案
还有问题
salamLogoImgFromToY = -(salamLogoIMG.frame.size.height + salamLogoImgOrigY) salamLogoImgFromToY 从不 (-) 减
关于ios - 如何在 swift UIView 类中设置新的 y 位置 ImageView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46075059/