From 44b36d7ace0519738b76e6ed8017914f7e72be70 Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Tue, 9 Aug 2016 00:26:34 -0500 Subject: [PATCH] Updates CheatsViewController to use CheatTableViewCell for vibrancy effects --- Delta.xcodeproj/project.pbxproj | 4 ++ Delta/Base.lproj/PauseMenu.storyboard | 51 +++++++++++++++---- .../Cheats/CheatTableViewCell.swift | 29 +++++++++++ .../Cheats/CheatsViewController.swift | 13 ++++- 4 files changed, 86 insertions(+), 11 deletions(-) create mode 100644 Delta/Pause Menu/Cheats/CheatTableViewCell.swift diff --git a/Delta.xcodeproj/project.pbxproj b/Delta.xcodeproj/project.pbxproj index fe29873..cf8083f 100644 --- a/Delta.xcodeproj/project.pbxproj +++ b/Delta.xcodeproj/project.pbxproj @@ -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 = ""; }; BFFA71E11AAC406100EE9DD1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; BFFA71E61AAC406100EE9DD1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; + BFFC464B1D5998D600AF2CC6 /* CheatTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CheatTableViewCell.swift; path = "Pause Menu/Cheats/CheatTableViewCell.swift"; sourceTree = ""; }; /* 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 */, diff --git a/Delta/Base.lproj/PauseMenu.storyboard b/Delta/Base.lproj/PauseMenu.storyboard index 17646a9..a552ae8 100644 --- a/Delta/Base.lproj/PauseMenu.storyboard +++ b/Delta/Base.lproj/PauseMenu.storyboard @@ -178,15 +178,48 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -205,7 +238,7 @@ - + @@ -219,10 +252,10 @@ - + - + @@ -247,10 +280,10 @@ - + - + @@ -275,10 +308,10 @@ - + - + diff --git a/Delta/Pause Menu/Cheats/CheatTableViewCell.swift b/Delta/Pause Menu/Cheats/CheatTableViewCell.swift new file mode 100644 index 0000000..7e23061 --- /dev/null +++ b/Delta/Pause Menu/Cheats/CheatTableViewCell.swift @@ -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() + } +} diff --git a/Delta/Pause Menu/Cheats/CheatsViewController.swift b/Delta/Pause Menu/Cheats/CheatsViewController.swift index 5172888..9fb1704 100644 --- a/Delta/Pause Menu/Cheats/CheatsViewController.swift +++ b/Delta/Pause Menu/Cheats/CheatsViewController.swift @@ -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 }