Added support for the change isTranslucent NavigationBar

This commit is contained in:
mrustaa
2023-12-24 00:43:06 +03:00
parent 8bff1e5c24
commit 831b2f144f
3 changed files with 57 additions and 6 deletions
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22155" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22131"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22504"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@@ -16,8 +16,29 @@
<view key="view" contentMode="scaleToFill" id="jmi-Lo-St4">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="gqJ-oN-JCK">
<rect key="frame" x="87.5" y="50" width="200" height="50"/>
<constraints>
<constraint firstAttribute="width" constant="200" id="3QE-nw-Od3"/>
<constraint firstAttribute="height" constant="50" id="MXC-rS-qfY"/>
</constraints>
<fontDescription key="fontDescription" name="HelveticaNeue-Bold" family="Helvetica Neue" pointSize="20"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" title="isTranslucent True">
<color key="titleColor" systemColor="systemBlueColor"/>
</state>
<connections>
<action selector="buttonChangeTranslucent:" destination="p3c-kf-PfN" eventType="touchUpInside" id="FG2-xH-GUG"/>
</connections>
</button>
</subviews>
<viewLayoutGuide key="safeArea" id="QCP-uk-H24"/>
<color key="backgroundColor" systemColor="opaqueSeparatorColor"/>
<constraints>
<constraint firstItem="gqJ-oN-JCK" firstAttribute="top" secondItem="QCP-uk-H24" secondAttribute="top" constant="30" id="2Vg-iw-6Rl"/>
<constraint firstItem="gqJ-oN-JCK" firstAttribute="centerX" secondItem="jmi-Lo-St4" secondAttribute="centerX" id="Crs-BD-puY"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Uzt-sR-4xA" sceneMemberID="firstResponder"/>
@@ -29,5 +50,8 @@
<systemColor name="opaqueSeparatorColor">
<color red="0.77647058820000003" green="0.77647058820000003" blue="0.7843137255" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemBlueColor">
<color red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
</resources>
</document>
@@ -31,9 +31,22 @@ class ExampleAddCollectionViewController: StoryboardController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.navigationBar.isTranslucent = true
container.move(type: .middle)
}
@IBAction func buttonChangeTranslucent(_ sender: UIButton) {
guard let translucent = navigationController?.navigationBar.isTranslucent else { return }
navigationController?.navigationBar.isTranslucent = !translucent
container.move(type: container.moveType)
}
func addCollectionView() -> UICollectionView {
let layout = UICollectionViewFlowLayout()