Skip to content
This repository has been archived by the owner on Aug 13, 2021. It is now read-only.

Commit

Permalink
Add width/height reactive properties to CALayer.
Browse files Browse the repository at this point in the history
  • Loading branch information
jverkoey committed Mar 20, 2017
1 parent 89b8ce2 commit da7f38d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/reactivetypes/ReactiveCALayer.swift
Expand Up @@ -74,6 +74,24 @@ public class ReactiveCALayer {
reactiveLayer: self)
}()

public lazy var width: ReactiveProperty<CGFloat> = {
let size = self.size
return createCoreAnimationProperty(#function,
initialValue: size.value.width,
externalWrite: { var dimensions = size.value; dimensions.width = $0; size.value = dimensions },
keyPath: "bounds.size.width",
reactiveLayer: self)
}()

public lazy var height: ReactiveProperty<CGFloat> = {
let size = self.size
return createCoreAnimationProperty(#function,
initialValue: size.value.height,
externalWrite: { var dimensions = size.value; dimensions.height = $0; size.value = dimensions },
keyPath: "bounds.size.height",
reactiveLayer: self)
}()

public lazy var anchorPoint: ReactiveProperty<CGPoint> = {
let layer = self.layer
return createCoreAnimationProperty(#function,
Expand Down

0 comments on commit da7f38d

Please sign in to comment.