Skip to content

Commit

Permalink
Fixed iPhoneX statusbar
Browse files Browse the repository at this point in the history
  • Loading branch information
PaoloCuscela committed Jan 6, 2018
1 parent db67568 commit 240ee3b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Cards.podspec
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Pod::Spec.new do |s|
s.name = 'Cards'
s.version = '1.3.0'
s.version = '1.3.1'
s.summary = 'Awesome iOS 11 appstore cards in swift 4.'
s.homepage = 'https://github.com/PaoloCuscela/Cards'
s.screenshots = 'https://raw.githubusercontent.com/PaoloCuscela/Cards/master/Images/Overview.png', 'https://raw.githubusercontent.com/PaoloCuscela/Cards/master/Images/CardGroupSliding.gif'
s.screenshots = 'https://raw.githubusercontent.com/PaoloCuscela/Cards/master/Images/Header.png', 'https://raw.githubusercontent.com/PaoloCuscela/Cards/master/Images/DetailView.gif'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'Paolo Cuscela' => 'cuscio.2@gmail.com'}
s.source = { :git => 'https://github.com/PaoloCuscela/Cards.git', :tag => s.version.to_s }
Expand Down
16 changes: 14 additions & 2 deletions Cards/Sources/DetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,19 @@ internal class DetailViewController: UIViewController {

fileprivate var xButton = XButton()

override var prefersStatusBarHidden: Bool {
if isFullscreen { return true }
else { return false }
}

//MARK: - View Lifecycle

override func viewDidLoad() {
super.viewDidLoad()

if #available(iOS 11.0, *) {
scrollView.contentInsetAdjustmentBehavior = .never
}

self.snap = UIScreen.main.snapshotView(afterScreenUpdates: true)
self.view.addSubview(blurView)
Expand Down Expand Up @@ -117,7 +126,10 @@ internal class DetailViewController: UIViewController {
}

if isFullscreen {
scrollView.frame = view.frame

scrollView.frame = view.bounds
scrollView.frame.origin.y = 0
print(scrollView.frame)

} else {
scrollView.frame.size = CGSize(width: LayoutHelper.XScreen(85), height: LayoutHelper.YScreen(100) - 20)
Expand Down Expand Up @@ -162,7 +174,7 @@ extension DetailViewController: UIScrollViewDelegate {
scrollView.contentOffset.y = 0
}

//card.delegate?.cardDetailIsScrolling?(card: card)
card.delegate?.cardDetailIsScrolling?(card: card)
}

public func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
Expand Down
35 changes: 21 additions & 14 deletions Demo/Demo/Storyboards/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="VB5-vT-PKk">
<device id="retina5_5" orientation="portrait">
<device id="retina5_9" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
Expand All @@ -16,7 +16,7 @@
<objects>
<viewController id="i4e-e4-FqZ" customClass="GroupViewController" customModule="Demo" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="5jG-it-e2N">
<rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Wa1-qf-6YE" customClass="CardGroupSliding" customModule="Cards">
Expand Down Expand Up @@ -63,7 +63,7 @@
<objects>
<viewController id="k06-gf-ALo" customClass="ArticleViewController" customModule="Demo" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="iMc-2y-m37">
<rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="MPq-Jv-zdb" customClass="CardArticle" customModule="Cards">
Expand Down Expand Up @@ -97,7 +97,7 @@
<objects>
<viewController id="LjN-1V-n2c" customClass="PlayerViewController" customModule="Demo" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="lMa-H4-g6c">
<rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="pRe-yW-fBP" customClass="CardPlayer" customModule="Cards">
Expand Down Expand Up @@ -130,7 +130,7 @@
<objects>
<viewController id="R2f-57-GXv" customClass="HighlightViewController" customModule="Demo" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="3tT-js-yj4">
<rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="gON-Ab-tsu" customClass="CardHighlight" customModule="Cards">
Expand All @@ -146,11 +146,14 @@
<userDefinedRuntimeAttribute type="image" keyPath="backgroundImage" value="flBackground"/>
</userDefinedRuntimeAttributes>
</view>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="uhT-Cy-Kvg" customClass="CardHighlight" customModule="Cards">
<rect key="frame" x="67" y="30" width="240" height="291"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="uhT-Cy-Kvg" customClass="CardHighlight" customModule="Cards">
<rect key="frame" x="67" y="44" width="240" height="288"/>
<color key="backgroundColor" red="1" green="0.49327188729999999" blue="0.47399842739999998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="tintColor" red="1" green="0.49327188729999999" blue="0.47399842739999998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="width" constant="240" id="a20-ls-Mga"/>
<constraint firstAttribute="width" secondItem="uhT-Cy-Kvg" secondAttribute="height" multiplier="5:6" id="s5a-1u-2IT"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="color" keyPath="textColor">
<color key="value" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
Expand All @@ -160,6 +163,10 @@
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="uhT-Cy-Kvg" firstAttribute="centerX" secondItem="Lys-bS-jq3" secondAttribute="centerX" id="P4y-6C-f8E"/>
<constraint firstItem="uhT-Cy-Kvg" firstAttribute="top" secondItem="3tT-js-yj4" secondAttribute="top" constant="44" id="ego-m5-A9N"/>
</constraints>
<viewLayoutGuide key="safeArea" id="Lys-bS-jq3"/>
</view>
<tabBarItem key="tabBarItem" title="Highlight" id="ecJ-Y5-JKF"/>
Expand Down Expand Up @@ -199,11 +206,11 @@
<objects>
<viewController storyboardIdentifier="CardContent" useStoryboardIdentifierAsRestorationIdentifier="YES" id="E9y-vp-odE" customClass="CardContentViewController" customModule="Demo" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" autoresizesSubviews="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" id="tif-Mz-Tb0">
<rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." textAlignment="justified" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="LfG-b8-HXd">
<rect key="frame" x="16" y="66" width="382" height="65"/>
<rect key="frame" x="16" y="90" width="343" height="65"/>
<constraints>
<constraint firstAttribute="height" constant="65" id="CTf-oC-n22"/>
</constraints>
Expand All @@ -212,13 +219,13 @@
<nil key="highlightedColor"/>
</label>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="flBackground" translatesAutoresizingMaskIntoConstraints="NO" id="VbH-UR-ElD">
<rect key="frame" x="0.0" y="146" width="414" height="120.33333333333331"/>
<rect key="frame" x="0.0" y="170" width="375" height="109"/>
<constraints>
<constraint firstAttribute="width" secondItem="VbH-UR-ElD" secondAttribute="height" multiplier="31:9" id="O79-xO-Pm3"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" textAlignment="justified" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ACX-JK-hQX">
<rect key="frame" x="16" y="281.66666666666669" width="382" height="165"/>
<rect key="frame" x="16" y="294.33333333333331" width="343" height="165"/>
<constraints>
<constraint firstAttribute="height" constant="165" id="ZUU-qo-q7r"/>
</constraints>
Expand All @@ -228,7 +235,7 @@
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Utd-w6-9A3">
<rect key="frame" x="0.0" y="471.66666666666669" width="414" height="35"/>
<rect key="frame" x="0.0" y="484.33333333333331" width="375" height="34.999999999999943"/>
<constraints>
<constraint firstAttribute="height" constant="35" id="cNP-rD-1oe"/>
</constraints>
Expand All @@ -238,7 +245,7 @@
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Welcome to Demo !!" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="cpR-bQ-f5O">
<rect key="frame" x="16" y="26" width="382" height="35"/>
<rect key="frame" x="16" y="50" width="343" height="35"/>
<constraints>
<constraint firstAttribute="height" constant="35" id="JlL-ep-lKm"/>
</constraints>
Expand Down

0 comments on commit 240ee3b

Please sign in to comment.