Skip to content

Commit

Permalink
Merge pull request #16 from cruisediary/perf/use-extension
Browse files Browse the repository at this point in the history
perf: use static let deviceSize
  • Loading branch information
cruisediary authored Jan 21, 2017
2 parents 5d479e1 + fd97ff7 commit fabcc58
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DeviceLayout.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'DeviceLayout'
s.version = '0.1.1'
s.version = '0.1.2'
s.summary = 'Auto Layout can be set differently for each device.'

# This description is used to generate tags and improve search results.
Expand Down
2 changes: 1 addition & 1 deletion Example/DeviceLayout/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
<real key="value" value="-110"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="inch12_9">
<real key="value" value="-12"/>
<real key="value" value="-120"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</constraint>
Expand Down
6 changes: 5 additions & 1 deletion Sources/DeviceLayoutConstraint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@ class DeviceLayoutConstraint: NSLayoutConstraint {
}

open func deviceSize() -> Size {
return Device.size()
return Device.deviceSize
}

open func layoutIfNeeded() {
self.firstItem.layoutIfNeeded()
self.secondItem?.layoutIfNeeded()
}
}

fileprivate extension Device {
static let deviceSize = Device.size()
}

0 comments on commit fabcc58

Please sign in to comment.