@@ -22,15 +22,21 @@ public struct ParallaxEffectOptions {
22
22
/// Custom container view that will be usead to apply subviews parallax effect
23
23
public var parallaxSubviewsContainer : UIView ?
24
24
/// A view that will be a container for the glow effect
25
- public weak var glowContainerView : UIView ?
25
+ public weak var glowContainerView : UIView ? {
26
+ didSet { oldValue? . removeFromSuperview ( ) }
27
+ }
26
28
/// Minimum vertical value at the most top position can be adjusted by this multipler
27
29
public var minVerticalPanGlowMultipler : Double = 0.2
28
30
/// Maximum vertical value at the most bottom position can be adjusted by this multipler
29
31
public var maxVerticalPanGlowMultipler : Double = 1.55
30
32
/// Alpha of the glow image view
31
- public var glowAlpha : Double = 1.0
33
+ public var glowAlpha : Double = 1.0 {
34
+ didSet { self . glowImageView. alpha = CGFloat ( glowAlpha) }
35
+ }
32
36
/// Glow effect image view
33
37
public var glowImageView : UIImageView = ParallaxEffectOptions . defaultGlowImageView ( )
38
+ /// Glow position
39
+ public var glowPosition : GlowPosition = . top
34
40
35
41
/// Constructor
36
42
///
@@ -44,6 +50,31 @@ public struct ParallaxEffectOptions {
44
50
45
51
}
46
52
53
+ extension ParallaxEffectOptions {
54
+
55
+ public struct GlowPosition {
56
+ let layout : ( UIView , UIImageView ) -> Void
57
+
58
+ public static let top : GlowPosition = . init( layout: { ( glowEffectContainerView, glowImageView) in
59
+ if let glowSuperView = glowEffectContainerView. superview {
60
+ glowEffectContainerView. frame = glowSuperView. bounds
61
+ }
62
+
63
+ // Make glow a litte bit bigger than the superview
64
+ let maxSize = max ( glowEffectContainerView. frame. width, glowEffectContainerView. frame. height) * 1.7
65
+ glowImageView. frame = CGRect ( x: 0 , y: 0 , width: maxSize, height: maxSize)
66
+
67
+ // Position in the middle and under the top edge of the superview
68
+ glowImageView. center = CGPoint ( x: glowEffectContainerView. frame. width/ 2 , y: - glowImageView. frame. height)
69
+ } )
70
+
71
+ public static let center : GlowPosition = . init( layout: { ( glowEffectContainerView, glowImageView) in
72
+ GlowPosition . top. layout ( glowEffectContainerView, glowImageView)
73
+ glowImageView. center = CGPoint ( x: glowEffectContainerView. frame. width/ 2 , y: - glowImageView. frame. height/ 2 )
74
+ } )
75
+ }
76
+ }
77
+
47
78
internal let glowImageAccessibilityIdentifier = " com.pgs-soft.parallaxview.gloweffect "
48
79
49
80
extension ParallaxEffectOptions {
0 commit comments