Reputation: 21
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)
}
}
i need to change y position of salamLogoIMG to salamLogoImgFromToY, if run new position line code in btn action its work, but i need set in first time, please help me
Upvotes: 0
Views: 117
Reputation:
ther are problem
salamLogoImgFromToY = -(salamLogoIMG.frame.size.height + salamLogoImgOrigY) salamLogoImgFromToY never (-) minus
Upvotes: 1
Reputation: 616
Try setting your frame in layoutsubviews
method of your UIView
class
Upvotes: 0