@@ -41,6 +41,20 @@ public class Zingle: UIView {
4141 return 0.0
4242 }
4343
44+ fileprivate var unhideYPositionForZingle : CGFloat {
45+ get {
46+ let yPos = self . yPosForZingal
47+ return yPos
48+ }
49+ }
50+
51+ fileprivate var hiddenYPositionForZingle : CGFloat {
52+ get {
53+ let yPos = self . yPosForZingal - heightForZingal
54+ return yPos
55+ }
56+ }
57+
4458 public init ( duration: TimeInterval = 0.3 , delay: TimeInterval = 2 ) {
4559
4660 self . completion = nil
@@ -79,7 +93,7 @@ extension Zingle {
7993
8094 fileprivate func setupView( ) {
8195 self . backgroundColor = UIColor . backgroundColor
82- self . frame = CGRect ( x: 0 , y: self . yPosForZingal , width: UIScreen . main. bounds. width, height: 0.0 )
96+ self . frame = CGRect ( x: 0 , y: self . hiddenYPositionForZingle , width: UIScreen . main. bounds. width, height: heightForZingal )
8397 }
8498
8599 fileprivate func setupMessageButton( ) {
@@ -151,11 +165,12 @@ extension Zingle {
151165 guard !self . isZingleShowing else {
152166 return
153167 }
168+
154169 self . isZingleShowing = true
170+ self . alpha = 1.0
155171
156172 UIView . animate ( withDuration: duration, animations: {
157- self . frame. size. height = self . heightForZingal
158- self . messageButton. frame. size. height = self . frame. size. height
173+ self . frame. origin. y = self . unhideYPositionForZingle
159174 self . layoutIfNeeded ( )
160175 } ) { _ in
161176 completion ( )
@@ -164,8 +179,8 @@ extension Zingle {
164179
165180 fileprivate func finishAnimating( ) {
166181 UIView . animate ( withDuration: duration, animations: {
167- self . frame. size . height = 0.0
168- self . messageButton . frame . size . height = self . frame . size . height
182+ self . frame. origin . y = self . hiddenYPositionForZingle
183+ self . alpha = 0.0
169184 self . layoutIfNeeded ( )
170185 } ) { _ in
171186 self . isZingleShowing = false
0 commit comments