Updates CheatsViewController to use CheatTableViewCell for vibrancy effects

This commit is contained in:
Riley Testut 2016-08-09 00:26:34 -05:00
parent d38b6bb981
commit 44b36d7ace
4 changed files with 86 additions and 11 deletions

View File

@ -63,6 +63,7 @@
BFFA71DD1AAC406100EE9DD1 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFFA71DC1AAC406100EE9DD1 /* AppDelegate.swift */; };
BFFA71E21AAC406100EE9DD1 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BFFA71E01AAC406100EE9DD1 /* Main.storyboard */; };
BFFA71E71AAC406100EE9DD1 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = BFFA71E51AAC406100EE9DD1 /* LaunchScreen.xib */; };
BFFC464C1D5998D600AF2CC6 /* CheatTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFFC464B1D5998D600AF2CC6 /* CheatTableViewCell.swift */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
@ -145,6 +146,7 @@
BFFA71DC1AAC406100EE9DD1 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
BFFA71E11AAC406100EE9DD1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
BFFA71E61AAC406100EE9DD1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = "<group>"; };
BFFC464B1D5998D600AF2CC6 /* CheatTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CheatTableViewCell.swift; path = "Pause Menu/Cheats/CheatTableViewCell.swift"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -320,6 +322,7 @@
isa = PBXGroup;
children = (
BFC9B7381CEFCD34008629BB /* CheatsViewController.swift */,
BFFC464B1D5998D600AF2CC6 /* CheatTableViewCell.swift */,
BF34FA061CF0F510006624C7 /* EditCheatViewController.swift */,
BF34FA101CF1899D006624C7 /* CheatTextView.swift */,
BF31878A1D489AAA00BD020D /* CheatValidator.swift */,
@ -565,6 +568,7 @@
BFC9B7391CEFCD34008629BB /* CheatsViewController.swift in Sources */,
BF353FFF1C5DA3C500C1184C /* PausePresentationController.swift in Sources */,
BF02BD001D361BD1000892F2 /* NSFetchedResultsController+Conveniences.m in Sources */,
BFFC464C1D5998D600AF2CC6 /* CheatTableViewCell.swift in Sources */,
BF7AE80A1C2E8C7600B1B5BC /* UIColor+Delta.swift in Sources */,
BF762E9E1BC19D31002C8866 /* DatabaseManager.swift in Sources */,
BF090CF41B490D8300DCAB45 /* UIDevice+Vibration.m in Sources */,

View File

@ -178,15 +178,48 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" id="e8g-ZW-5lQ">
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" id="e8g-ZW-5lQ" customClass="CheatTableViewCell" customModule="Delta" customModuleProvider="target">
<frame key="frameInset" minY="92" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="e8g-ZW-5lQ" id="AHE-Jk-ULE">
<frame key="frameInset" width="375" height="43"/>
<frame key="frameInset" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<visualEffectView opaque="NO" contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="emc-gw-KkJ" userLabel="Selected Background View">
<frame key="frameInset" maxY="-0.5"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" ambiguous="YES" id="9bA-Tg-Bko">
<frame key="frameInset"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<vibrancyEffect>
<blurEffect style="dark"/>
</vibrancyEffect>
</visualEffectView>
<visualEffectView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="R4A-9d-DGb">
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="EdX-fU-x54">
<frame key="frameInset"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</view>
<vibrancyEffect>
<blurEffect style="dark"/>
</vibrancyEffect>
</visualEffectView>
</subviews>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="R4A-9d-DGb" firstAttribute="top" secondItem="AHE-Jk-ULE" secondAttribute="top" id="58j-J1-xfR"/>
<constraint firstItem="R4A-9d-DGb" firstAttribute="leading" secondItem="AHE-Jk-ULE" secondAttribute="leading" id="e2C-LI-ckx"/>
<constraint firstAttribute="bottom" secondItem="R4A-9d-DGb" secondAttribute="bottom" id="rpD-aC-yxP"/>
<constraint firstAttribute="trailing" secondItem="R4A-9d-DGb" secondAttribute="trailing" id="tqu-hT-J2F"/>
</constraints>
</tableViewCellContentView>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<connections>
<outlet property="selectedBackgroundView" destination="emc-gw-KkJ" id="bqb-2h-Wl2"/>
<outlet property="vibrancyView" destination="R4A-9d-DGb" id="k1f-zO-bge"/>
</connections>
</tableViewCell>
</prototypes>
<connections>
@ -205,7 +238,7 @@
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="loJ-rc-I6l" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1702" y="1377"/>
<point key="canvasLocation" x="1701.5999999999999" y="1376.7616191904049"/>
</scene>
<!--Cheat-->
<scene sceneID="SMZ-Ah-CVb">
@ -219,10 +252,10 @@
<tableViewSection headerTitle="Name" id="QT6-DZ-g70">
<cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" id="ZeC-rg-QFa">
<rect key="frame" x="0.0" y="120" width="375" height="44"/>
<rect key="frame" x="0.0" y="119.5" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" tableViewCell="ZeC-rg-QFa" id="UIF-fK-ApW">
<frame key="frameInset" width="375" height="43"/>
<frame key="frameInset" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Cheat Name" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="DD1-X0-hg7">
@ -247,10 +280,10 @@
<tableViewSection headerTitle="Type" footerTitle="Description" id="rvn-VK-2uH">
<cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" id="Tst-zn-e04">
<rect key="frame" x="0.0" y="228" width="375" height="44"/>
<rect key="frame" x="0.0" y="227" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" tableViewCell="Tst-zn-e04" id="gwV-zS-RWQ">
<frame key="frameInset" width="375" height="43"/>
<frame key="frameInset" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<segmentedControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="xrD-ue-96Q">
@ -275,10 +308,10 @@
<tableViewSection headerTitle="Code" footerTitle="Description" id="rHC-nA-ga0">
<cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" rowHeight="210" id="xxc-cz-sb7">
<rect key="frame" x="0.0" y="348" width="375" height="210"/>
<rect key="frame" x="0.0" y="346.5" width="375" height="210"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" tableViewCell="xxc-cz-sb7" id="agU-SE-fNa">
<frame key="frameInset" width="375" height="209"/>
<frame key="frameInset" width="375" height="209.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" text="XXXXXXXX YYYYYYYY" translatesAutoresizingMaskIntoConstraints="NO" id="a17-LB-QXD" customClass="CheatTextView" customModule="Delta" customModuleProvider="target">

View File

@ -0,0 +1,29 @@
//
// CheatTableViewCell.swift
// Delta
//
// Created by Riley Testut on 8/8/16.
// Copyright © 2016 Riley Testut. All rights reserved.
//
import UIKit
class CheatTableViewCell: UITableViewCell
{
@IBOutlet private var vibrancyView: UIVisualEffectView!
override func layoutSubviews()
{
if let textLabel = self.textLabel
{
self.vibrancyView.contentView.addSubview(textLabel)
}
if let detailTextLabel = self.detailTextLabel
{
self.vibrancyView.contentView.addSubview(detailTextLabel)
}
super.layoutSubviews()
}
}

View File

@ -42,14 +42,22 @@ extension CheatsViewController
self.title = NSLocalizedString("Cheats", comment: "")
self.backgroundView = RSTBackgroundView(frame: self.view.bounds)
let vibrancyEffect = UIVibrancyEffect(blurEffect: UIBlurEffect(style: .dark))
let vibrancyView = UIVisualEffectView(effect: vibrancyEffect)
vibrancyView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
self.tableView.backgroundView = vibrancyView
self.backgroundView = RSTBackgroundView(frame: CGRect(x: 0, y: 0, width: vibrancyView.bounds.width, height: vibrancyView.bounds.height))
self.backgroundView.isHidden = false
self.backgroundView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
self.backgroundView.textLabel.text = NSLocalizedString("No Cheats", comment: "")
self.backgroundView.textLabel.textColor = UIColor.white
self.backgroundView.detailTextLabel.text = NSLocalizedString("You can add a new cheat by pressing the + button in the top right.", comment: "")
self.backgroundView.detailTextLabel.textColor = UIColor.white
self.tableView.backgroundView = self.backgroundView
vibrancyView.contentView.addSubview(self.backgroundView)
self.tableView.separatorEffect = vibrancyEffect
self.registerForPreviewing(with: self, sourceView: self.tableView)
}
@ -140,6 +148,7 @@ private extension CheatsViewController
let cheat = self.fetchedResultsController.object(at: indexPath) as! Cheat
cell.textLabel?.text = cheat.name
cell.textLabel?.font = UIFont.boldSystemFont(ofSize: cell.textLabel!.font.pointSize)
cell.textLabel?.textColor = UIColor.white
cell.accessoryType = cheat.enabled ? .checkmark : .none
}