add EditProfileColoredTitleCell

This commit is contained in:
nixzhu
2015-04-27 13:44:13 +08:00
parent 3946ce4af4
commit e3834cec4c
5 changed files with 150 additions and 22 deletions
+16
View File
@@ -104,6 +104,8 @@
50894D031AEA6433000981AF /* EditProfileLessInfoCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 50894D011AEA6433000981AF /* EditProfileLessInfoCell.xib */; };
50894D071AEDFDA2000981AF /* EditProfileMoreInfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50894D051AEDFDA2000981AF /* EditProfileMoreInfoCell.swift */; };
50894D081AEDFDA2000981AF /* EditProfileMoreInfoCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 50894D061AEDFDA2000981AF /* EditProfileMoreInfoCell.xib */; };
50894D0C1AEE0177000981AF /* EditProfileColoredTitleCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50894D0A1AEE0177000981AF /* EditProfileColoredTitleCell.swift */; };
50894D0D1AEE0177000981AF /* EditProfileColoredTitleCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 50894D0B1AEE0177000981AF /* EditProfileColoredTitleCell.xib */; };
508C2AA01AD648B2002B8097 /* SearchUsersViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 508C2A9F1AD648B2002B8097 /* SearchUsersViewController.swift */; };
508C2AA41AD661B3002B8097 /* UserStateCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 508C2AA21AD661B3002B8097 /* UserStateCell.swift */; };
508C2AA51AD661B3002B8097 /* UserStateCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 508C2AA31AD661B3002B8097 /* UserStateCell.xib */; };
@@ -261,6 +263,8 @@
50894D011AEA6433000981AF /* EditProfileLessInfoCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = EditProfileLessInfoCell.xib; path = Views/Cells/EditProfileLessInfo/EditProfileLessInfoCell.xib; sourceTree = "<group>"; };
50894D051AEDFDA2000981AF /* EditProfileMoreInfoCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = EditProfileMoreInfoCell.swift; path = Views/Cells/EditProfileMoreInfo/EditProfileMoreInfoCell.swift; sourceTree = "<group>"; };
50894D061AEDFDA2000981AF /* EditProfileMoreInfoCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = EditProfileMoreInfoCell.xib; path = Views/Cells/EditProfileMoreInfo/EditProfileMoreInfoCell.xib; sourceTree = "<group>"; };
50894D0A1AEE0177000981AF /* EditProfileColoredTitleCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = EditProfileColoredTitleCell.swift; path = Views/Cells/EditProfileColoredTitle/EditProfileColoredTitleCell.swift; sourceTree = "<group>"; };
50894D0B1AEE0177000981AF /* EditProfileColoredTitleCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = EditProfileColoredTitleCell.xib; path = Views/Cells/EditProfileColoredTitle/EditProfileColoredTitleCell.xib; sourceTree = "<group>"; };
508C2A9F1AD648B2002B8097 /* SearchUsersViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SearchUsersViewController.swift; path = ViewControllers/SearchUsers/SearchUsersViewController.swift; sourceTree = "<group>"; };
508C2AA21AD661B3002B8097 /* UserStateCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = UserStateCell.swift; path = Views/Cells/UserState/UserStateCell.swift; sourceTree = "<group>"; };
508C2AA31AD661B3002B8097 /* UserStateCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = UserStateCell.xib; path = Views/Cells/UserState/UserStateCell.xib; sourceTree = "<group>"; };
@@ -550,6 +554,7 @@
50894CFC1AEA54BE000981AF /* SettingsMore */,
50894D041AEA6439000981AF /* EditProfileLessInfo */,
50894D091AEDFDA6000981AF /* EditProfileMoreInfo */,
50894D0E1AEE017B000981AF /* EditProfileColoredTitle */,
);
name = Cells;
sourceTree = "<group>";
@@ -836,6 +841,15 @@
name = EditProfileMoreInfo;
sourceTree = "<group>";
};
50894D0E1AEE017B000981AF /* EditProfileColoredTitle */ = {
isa = PBXGroup;
children = (
50894D0A1AEE0177000981AF /* EditProfileColoredTitleCell.swift */,
50894D0B1AEE0177000981AF /* EditProfileColoredTitleCell.xib */,
);
name = EditProfileColoredTitle;
sourceTree = "<group>";
};
508C2AA11AD648BE002B8097 /* SearchUsers */ = {
isa = PBXGroup;
children = (
@@ -1123,6 +1137,7 @@
505EC8181ADF8151001D27E0 /* SkillCategoryCell.xib in Resources */,
505EC81D1ADFBE1B001D27E0 /* SkillSelectionCell.xib in Resources */,
50EB8CC01AE89ED8001AC1EE /* ChatLeftVideoCell.xib in Resources */,
50894D0D1AEE0177000981AF /* EditProfileColoredTitleCell.xib in Resources */,
50CDBE431ACA9B4200459CE0 /* ChatRightImageCell.xib in Resources */,
508C2AA51AD661B3002B8097 /* UserStateCell.xib in Resources */,
50E114FD1ABC549300F13000 /* ContactsCell.xib in Resources */,
@@ -1304,6 +1319,7 @@
505EC8171ADF8151001D27E0 /* SkillCategoryCell.swift in Sources */,
50894CF51AEA4A01000981AF /* SettingsUserCell.swift in Sources */,
504F415A1AD5028200FBB19A /* SkillCell.swift in Sources */,
50894D0C1AEE0177000981AF /* EditProfileColoredTitleCell.swift in Sources */,
5023DE521AB6C51300B3EE96 /* CGRect+Yep.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -20,6 +20,7 @@ class EditProfileViewController: UIViewController {
let editProfileLessInfoCellIdentifier = "EditProfileLessInfoCell"
let editProfileMoreInfoCellIdentifier = "EditProfileMoreInfoCell"
let editProfileColoredTitleCellIdentifier = "EditProfileColoredTitleCell"
override func viewDidLoad() {
super.viewDidLoad()
@@ -43,36 +44,68 @@ class EditProfileViewController: UIViewController {
editProfileTableView.registerNib(UINib(nibName: editProfileLessInfoCellIdentifier, bundle: nil), forCellReuseIdentifier: editProfileLessInfoCellIdentifier)
editProfileTableView.registerNib(UINib(nibName: editProfileMoreInfoCellIdentifier, bundle: nil), forCellReuseIdentifier: editProfileMoreInfoCellIdentifier)
editProfileTableView.registerNib(UINib(nibName: editProfileColoredTitleCellIdentifier, bundle: nil), forCellReuseIdentifier: editProfileColoredTitleCellIdentifier)
}
}
extension EditProfileViewController: UITableViewDataSource, UITableViewDelegate {
enum Row: Int {
enum Section: Int {
case Info
case LogOut
}
enum InfoRow: Int {
case Name = 0
case Intro
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 2
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
switch indexPath.row {
case Row.Name.rawValue:
let cell = tableView.dequeueReusableCellWithIdentifier(editProfileLessInfoCellIdentifier) as! EditProfileLessInfoCell
cell.annotationLabel.text = NSLocalizedString("Nickname", comment: "")
cell.infoLabel.text = YepUserDefaults.nickname()
return cell
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
case Row.Intro.rawValue:
let cell = tableView.dequeueReusableCellWithIdentifier(editProfileMoreInfoCellIdentifier) as! EditProfileMoreInfoCell
cell.annotationLabel.text = NSLocalizedString("Introduction", comment: "")
cell.infoLabel.text = "I'm good at iOS Development and Singing. Come here, let me teach you."
switch section {
case Section.Info.rawValue:
return 2
case Section.LogOut.rawValue:
return 1
default:
return 0
}
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
switch indexPath.section {
case Section.Info.rawValue:
switch indexPath.row {
case InfoRow.Name.rawValue:
let cell = tableView.dequeueReusableCellWithIdentifier(editProfileLessInfoCellIdentifier) as! EditProfileLessInfoCell
cell.annotationLabel.text = NSLocalizedString("Nickname", comment: "")
cell.infoLabel.text = YepUserDefaults.nickname()
return cell
case InfoRow.Intro.rawValue:
let cell = tableView.dequeueReusableCellWithIdentifier(editProfileMoreInfoCellIdentifier) as! EditProfileMoreInfoCell
cell.annotationLabel.text = NSLocalizedString("Introduction", comment: "")
cell.infoLabel.text = "I'm good at iOS Development and Singing. Come here, let me teach you."
return cell
default:
return UITableViewCell()
}
case Section.LogOut.rawValue:
let cell = tableView.dequeueReusableCellWithIdentifier(editProfileColoredTitleCellIdentifier) as! EditProfileColoredTitleCell
cell.coloredTitleLabel.text = NSLocalizedString("Log out", comment: "")
cell.coloredTitleColor = UIColor.redColor()
return cell
default:
@@ -81,11 +114,23 @@ extension EditProfileViewController: UITableViewDataSource, UITableViewDelegate
}
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
switch indexPath.row {
case Row.Name.rawValue:
return 60
case Row.Intro.rawValue:
return 120
switch indexPath.section {
case Section.Info.rawValue:
switch indexPath.row {
case InfoRow.Name.rawValue:
return 60
case InfoRow.Intro.rawValue:
return 120
default:
return 0
}
case Section.LogOut.rawValue:
return 80
default:
return 0
}
@@ -0,0 +1,33 @@
//
// EditProfileColoredTitleCell.swift
// Yep
//
// Created by NIX on 15/4/27.
// Copyright (c) 2015 Catch Inc. All rights reserved.
//
import UIKit
class EditProfileColoredTitleCell: UITableViewCell {
var coloredTitleColor: UIColor = UIColor.redColor() {
willSet {
coloredTitleLabel.textColor = newValue
}
}
@IBOutlet weak var coloredTitleLabel: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7702" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7701"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="EditProfileColoredTitleCell" rowHeight="74" id="KGk-i7-Jjw" customClass="EditProfileColoredTitleCell" customModule="Yep" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="320" height="74"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Colored Title" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="MHA-rr-62L">
<rect key="frame" x="111" y="26" width="98" height="22"/>
<fontDescription key="fontDescription" type="system" weight="light" pointSize="18"/>
<color key="textColor" red="1" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstAttribute="centerY" secondItem="MHA-rr-62L" secondAttribute="centerY" id="sxx-f9-Lo6"/>
<constraint firstAttribute="centerX" secondItem="MHA-rr-62L" secondAttribute="centerX" id="zNx-WP-eVR"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="coloredTitleLabel" destination="MHA-rr-62L" id="gF4-Qa-PTg"/>
</connections>
<point key="canvasLocation" x="338" y="387"/>
</tableViewCell>
</objects>
</document>
@@ -6,7 +6,7 @@
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="111" id="KGk-i7-Jjw" customClass="EditProfileMoreInfoCell" customModule="Yep" customModuleProvider="target">
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="EditProfileMoreInfoCell" rowHeight="111" id="KGk-i7-Jjw" customClass="EditProfileMoreInfoCell" customModule="Yep" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="320" height="111"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">