Skip to content

Commit

Permalink
resize mklayer with superview's bounds change
Browse files Browse the repository at this point in the history
  • Loading branch information
nghialv committed Dec 9, 2014
1 parent 460f693 commit 2d7a3bf
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 14 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "../Source/MKTextField.swift"
timestampString = "438329788.240539"
timestampString = "439825393.034166"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "167"
endingLineNumber = "167"
startingLineNumber = "172"
endingLineNumber = "172"
landmarkName = "setFloatingLabelOverlapTextField()"
landmarkType = "5">
</BreakpointContent>
Expand All @@ -42,11 +42,11 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "../Source/MKLabel.swift"
timestampString = "438939665.068929"
timestampString = "439825393.034166"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "91"
endingLineNumber = "91"
startingLineNumber = "95"
endingLineNumber = "95"
landmarkName = "touchesBegan(_:withEvent:)"
landmarkType = "5">
</BreakpointContent>
Expand Down
10 changes: 5 additions & 5 deletions Example/MaterialKit/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6250" systemVersion="14C68m" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="Nz2-bn-2Jh">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6254" systemVersion="14C78c" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="Nz2-bn-2Jh">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6244"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
</dependencies>
<scenes>
<!--Navigation Controller-->
Expand Down Expand Up @@ -178,15 +178,15 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="wall-e.png" translatesAutoresizingMaskIntoConstraints="NO" id="XRE-rZ-Wco" customClass="MKImageView" customModule="MaterialKit" customModuleProvider="target">
<rect key="frame" x="67" y="186" width="240" height="128"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="MKLabel" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="WKH-q6-GEt" customClass="MKLabel" customModule="MaterialKit" customModuleProvider="target">
<rect key="frame" x="137" y="92" width="100" height="45"/>
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="wall-e.png" translatesAutoresizingMaskIntoConstraints="NO" id="XRE-rZ-Wco" customClass="MKImageView" customModule="MaterialKit" customModuleProvider="target">
<rect key="frame" x="67" y="186" width="240" height="128"/>
</imageView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
Expand Down
7 changes: 6 additions & 1 deletion Source/MKButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ class MKButton : UIButton
mkLayer.setBackgroundLayerColor(backgroundLayerColor)
}
}

override var bounds: CGRect {
didSet {
mkLayer.superLayerDidResize()
}
}

private lazy var mkLayer: MKLayer = MKLayer(superLayer: self.layer)

// MARK - initilization
Expand Down
6 changes: 5 additions & 1 deletion Source/MKImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ class MKImageView: UIImageView
mkLayer.setBackgroundLayerColor(backgroundLayerColor)
}
}

override var bounds: CGRect {
didSet {
mkLayer.superLayerDidResize()
}
}
private lazy var mkLayer: MKLayer = MKLayer(superLayer: self.layer)

override init() {
Expand Down
6 changes: 5 additions & 1 deletion Source/MKLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ class MKLabel: UILabel {
mkLayer.setBackgroundLayerColor(backgroundLayerColor)
}
}

override var bounds: CGRect {
didSet {
mkLayer.superLayerDidResize()
}
}
private lazy var mkLayer: MKLayer = MKLayer(superLayer: self.layer)

override init() {
Expand Down
5 changes: 5 additions & 0 deletions Source/MKTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ class MKTextField : UITextField {
setFloatingLabelOverlapTextField()
}
}
override var bounds: CGRect {
didSet {
mkLayer.superLayerDidResize()
}
}

private lazy var mkLayer: MKLayer = MKLayer(superLayer: self.layer)
private var floatingLabel: UILabel!
Expand Down

0 comments on commit 2d7a3bf

Please sign in to comment.