Skip to content

Commit

Permalink
侧滑菜单弹出收回动画完成 并重新抽象问题 修正了UI变化逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
zpz1237 committed Oct 14, 2015

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 11ae880 commit bac1a69
Showing 9 changed files with 84 additions and 27 deletions.
23 changes: 23 additions & 0 deletions zhihuDaily 2.0/Assets.xcassets/menu.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_menu_black_24dp.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 27 additions & 4 deletions zhihuDaily 2.0/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8191" systemVersion="15B30a" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="9Uf-XC-sul">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8191" systemVersion="15B30a" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="4ba-nh-i6M">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
@@ -99,7 +99,7 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="今日热闻" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sGS-Tw-Wou">
<rect key="frame" x="8" y="12" width="224" height="21"/>
<rect key="frame" x="8" y="4" width="224" height="21"/>
<animations/>
<fontDescription key="fontDescription" style="UICTFontTextStyleHeadline"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="calibratedRGB"/>
@@ -275,7 +275,7 @@
<rect key="frame" x="0.0" y="0.0" width="600" height="125"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="placeHolderB" translatesAutoresizingMaskIntoConstraints="NO" id="xeA-G9-O3O">
<rect key="frame" x="0.0" y="-1" width="225" height="126"/>
<rect key="frame" x="-1" y="-1" width="225" height="126"/>
<animations/>
<constraints>
<constraint firstAttribute="width" constant="225" id="CcD-Ao-nfT"/>
@@ -288,7 +288,7 @@
<constraints>
<constraint firstAttribute="height" constant="125" id="Ij9-a4-DC2"/>
<constraint firstAttribute="bottom" secondItem="xeA-G9-O3O" secondAttribute="bottom" id="UOZ-Sh-jyN"/>
<constraint firstItem="xeA-G9-O3O" firstAttribute="leading" secondItem="bre-Vx-jSP" secondAttribute="leading" id="ZSO-HR-E1U"/>
<constraint firstItem="xeA-G9-O3O" firstAttribute="leading" secondItem="bre-Vx-jSP" secondAttribute="leading" constant="-1" id="ZSO-HR-E1U"/>
<constraint firstItem="xeA-G9-O3O" firstAttribute="top" secondItem="bre-Vx-jSP" secondAttribute="top" constant="-1" id="afR-mg-nfa"/>
</constraints>
</view>
@@ -429,6 +429,29 @@
</objects>
<point key="canvasLocation" x="-463" y="407"/>
</scene>
<!--Reveal View Controller-->
<scene sceneID="PDx-x5-Vl6">
<objects>
<viewController id="4ba-nh-i6M" customClass="SWRevealViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="NEb-xE-Ur7"/>
<viewControllerLayoutGuide type="bottom" id="w0a-8w-b3v"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="zQV-7o-q9N">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<connections>
<segue destination="9Uf-XC-sul" kind="custom" identifier="sw_rear" customClass="SWRevealViewControllerSegueSetController" id="wgx-xy-w13"/>
<segue destination="eJm-Aj-C4A" kind="custom" identifier="sw_front" customClass="SWRevealViewControllerSegueSetController" id="PgJ-Sp-ZXF"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="XwT-8z-ru7" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-463" y="-333"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="3yj-7e-TfO">
<objects>
2 changes: 0 additions & 2 deletions zhihuDaily 2.0/HomeSideCell.swift
Original file line number Diff line number Diff line change
@@ -14,8 +14,6 @@ class HomeSideCell: UITableViewCell {
@IBOutlet weak var homeTitleLabel: UILabel!
@IBOutlet weak var homeSwitchImageView: UIImageView!

var configured = true

override func awakeFromNib() {
super.awakeFromNib()

8 changes: 7 additions & 1 deletion zhihuDaily 2.0/MainTableViewController.swift
Original file line number Diff line number Diff line change
@@ -11,10 +11,15 @@ import UIKit
class MainTableViewController: UITableViewController, SDCycleScrollViewDelegate, ParallaxHeaderViewDelegate {

@IBOutlet weak var dateLabel: UILabel!

override func viewDidLoad() {
super.viewDidLoad()

//创建leftBarButtonItem以及添加手势识别
let leftButton = UIBarButtonItem(image: UIImage(named: "menu"), style: .Plain, target: self.revealViewController(), action: "revealToggle:")
leftButton.tintColor = UIColor.whiteColor()
self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())

//生成第二启动页背景
let launchView = UIView(frame: CGRectMake(0, -64, self.view.frame.width, self.view.frame.height))
launchView.alpha = 0.99
@@ -37,6 +42,7 @@ class MainTableViewController: UITableViewController, SDCycleScrollViewDelegate,
UIView.animateWithDuration(0.2, animations: { () -> Void in
launchView.alpha = 0
self.navigationItem.titleView?.hidden = false
self.navigationItem.setLeftBarButtonItem(leftButton, animated: false)
}, completion: { (finished) -> Void in
launchView.removeFromSuperview()
})
10 changes: 5 additions & 5 deletions zhihuDaily 2.0/SWRevealViewController/SWRevealViewController.m
Original file line number Diff line number Diff line change
@@ -1708,11 +1708,11 @@ - (void)loadStoryboardControllers
}
@catch(NSException *exception) {}

@try
{
[self performSegueWithIdentifier:SWSegueRightIdentifier sender:nil];
}
@catch(NSException *exception) {}
// @try
// {
// [self performSegueWithIdentifier:SWSegueRightIdentifier sender:nil];
// }
// @catch(NSException *exception) {}
}
}

37 changes: 22 additions & 15 deletions zhihuDaily 2.0/SideMenuViewController.swift
Original file line number Diff line number Diff line change
@@ -13,6 +13,13 @@ class SideMenuViewController: UIViewController {
@IBOutlet weak var tableView: UITableView!

var blurView: GradientView!
var originState = true {
didSet {
if oldValue != originState {
self.tableView.reloadRowsAtIndexPaths([NSIndexPath(forRow: 0, inSection: 0)], withRowAnimation: .None)
}
}
}

override func viewDidLoad() {
super.viewDidLoad()
@@ -35,6 +42,11 @@ class SideMenuViewController: UIViewController {
func appCloud() -> AppDelegate {
return UIApplication.sharedApplication().delegate as! AppDelegate
}

//更改StatusBar颜色
override func preferredStatusBarStyle() -> UIStatusBarStyle {
return .LightContent
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
@@ -51,6 +63,11 @@ extension SideMenuViewController: UITableViewDataSource, UITableViewDelegate {
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
if indexPath.row == 0 {
let cell = tableView.dequeueReusableCellWithIdentifier("homeSideCell") as! HomeSideCell
if originState == false {
cell.contentView.backgroundColor = UIColor(red: 19/255.0, green: 26/255.0, blue: 32/255.0, alpha: 1)
cell.homeImageView.tintColor = UIColor(red: 136/255.0, green: 141/255.0, blue: 145/255.0, alpha: 1)
cell.homeTitleLabel.textColor = UIColor(red: 136/255.0, green: 141/255.0, blue: 145/255.0, alpha: 1)
}
return cell
}
let cell = tableView.dequeueReusableCellWithIdentifier("contentSideCell") as! ContentSideCell
@@ -59,24 +76,14 @@ extension SideMenuViewController: UITableViewDataSource, UITableViewDelegate {
}

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
//若非选中HomeSideCell 且其UI为初始选中状态 则改变其UI为未选中状态 同时更改标志量
//初始状态结束 回归正常UI搭配
if let _ = tableView.cellForRowAtIndexPath(indexPath) as? ContentSideCell {
if let cell = tableView.cellForRowAtIndexPath(NSIndexPath(forRow: 0, inSection: 0)) as? HomeSideCell {
if cell.configured {
cell.contentView.backgroundColor = UIColor(red: 19/255.0, green: 26/255.0, blue: 32/255.0, alpha: 1)
cell.homeImageView.tintColor = UIColor(red: 136/255.0, green: 141/255.0, blue: 145/255.0, alpha: 1)
cell.homeTitleLabel.textColor = UIColor(red: 136/255.0, green: 141/255.0, blue: 145/255.0, alpha: 1)
cell.configured = false
}
}
originState = false
}
//若选中HomeSideCell 而其UI为未选中状态 则改变其UI为选中状态 同时更改标志量 (因无法设置HightLightedTintColor)
//初始状态结束 回归正常UI搭配 且协助设置选中状态UI
if let cell = tableView.cellForRowAtIndexPath(indexPath) as? HomeSideCell {
if cell.configured == false {
cell.homeImageView.tintColor = UIColor.whiteColor()
//换种思路来想 这句不需要存在
//cell.configured = true
}
originState = false
cell.homeImageView.tintColor = UIColor.whiteColor()
}
}

0 comments on commit bac1a69

Please sign in to comment.