From bb088ec5aab5fbb5cd23459e01d2f99226d53c40 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Tue, 12 May 2015 06:42:23 +0800 Subject: [PATCH] add ProfileSeparationLineCell; adjust section insets --- Yep.xcodeproj/project.pbxproj | 16 ++++++++ .../Profile/ProfileViewController.swift | 33 +++++++++++---- .../ProfileSeparationLineCell.swift | 41 +++++++++++++++++++ .../ProfileSeparationLineCell.xib | 20 +++++++++ 4 files changed, 102 insertions(+), 8 deletions(-) create mode 100644 Yep/Views/Cells/ProfileSeparationLine/ProfileSeparationLineCell.swift create mode 100644 Yep/Views/Cells/ProfileSeparationLine/ProfileSeparationLineCell.xib diff --git a/Yep.xcodeproj/project.pbxproj b/Yep.xcodeproj/project.pbxproj index cfc19511..2c57b2e8 100644 --- a/Yep.xcodeproj/project.pbxproj +++ b/Yep.xcodeproj/project.pbxproj @@ -135,6 +135,8 @@ 508D17481ACCF4710092D666 /* ChatLeftAudioCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 508D17461ACCF4710092D666 /* ChatLeftAudioCell.xib */; }; 508D174C1ACCF49B0092D666 /* ChatRightAudioCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 508D174A1ACCF49B0092D666 /* ChatRightAudioCell.swift */; }; 508D174D1ACCF49B0092D666 /* ChatRightAudioCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 508D174B1ACCF49B0092D666 /* ChatRightAudioCell.xib */; }; + 508F8FC81B0161EF00461B0B /* ProfileSeparationLineCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 508F8FC61B0161EF00461B0B /* ProfileSeparationLineCell.swift */; }; + 508F8FC91B0161EF00461B0B /* ProfileSeparationLineCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 508F8FC71B0161EF00461B0B /* ProfileSeparationLineCell.xib */; }; 5099B9C41AB9510D002F940B /* RankView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5099B9C31AB9510D002F940B /* RankView.swift */; }; 5099B9C71AB99F7B002F940B /* RegisterPickAvatarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5099B9C61AB99F7B002F940B /* RegisterPickAvatarViewController.swift */; }; 5099B9C91AB9A7CB002F940B /* CameraPreviewView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5099B9C81AB9A7CB002F940B /* CameraPreviewView.swift */; }; @@ -314,6 +316,8 @@ 508D17461ACCF4710092D666 /* ChatLeftAudioCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = ChatLeftAudioCell.xib; path = Views/Cells/ChatLeftAudio/ChatLeftAudioCell.xib; sourceTree = ""; }; 508D174A1ACCF49B0092D666 /* ChatRightAudioCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ChatRightAudioCell.swift; path = Views/Cells/ChatRightAudio/ChatRightAudioCell.swift; sourceTree = ""; }; 508D174B1ACCF49B0092D666 /* ChatRightAudioCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = ChatRightAudioCell.xib; path = Views/Cells/ChatRightAudio/ChatRightAudioCell.xib; sourceTree = ""; }; + 508F8FC61B0161EF00461B0B /* ProfileSeparationLineCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ProfileSeparationLineCell.swift; path = Views/Cells/ProfileSeparationLine/ProfileSeparationLineCell.swift; sourceTree = ""; }; + 508F8FC71B0161EF00461B0B /* ProfileSeparationLineCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = ProfileSeparationLineCell.xib; path = Views/Cells/ProfileSeparationLine/ProfileSeparationLineCell.xib; sourceTree = ""; }; 5099B9C31AB9510D002F940B /* RankView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RankView.swift; path = Views/Rank/RankView.swift; sourceTree = ""; }; 5099B9C61AB99F7B002F940B /* RegisterPickAvatarViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RegisterPickAvatarViewController.swift; path = ViewControllers/Register/RegisterPickAvatarViewController.swift; sourceTree = ""; }; 5099B9C81AB9A7CB002F940B /* CameraPreviewView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CameraPreviewView.swift; path = Views/CameraPreview/CameraPreviewView.swift; sourceTree = ""; }; @@ -634,6 +638,7 @@ 504F415C1AD5028500FBB19A /* Skill */, 502AE5501AB93178005BD199 /* ProfileHeader */, 502AE5551AB93218005BD199 /* ProfileFooter */, + 508F8FCA1B0161F400461B0B /* ProfileSeparationLine */, 0A9018801B01152D00AE4B7F /* ProfileSocialAccount */, 50E114FE1ABC549800F13000 /* Contacts */, 503315991AC101830008A209 /* ChatLeftText */, @@ -1042,6 +1047,15 @@ name = ChatRightAudio; sourceTree = ""; }; + 508F8FCA1B0161F400461B0B /* ProfileSeparationLine */ = { + isa = PBXGroup; + children = ( + 508F8FC61B0161EF00461B0B /* ProfileSeparationLineCell.swift */, + 508F8FC71B0161EF00461B0B /* ProfileSeparationLineCell.xib */, + ); + name = ProfileSeparationLine; + sourceTree = ""; + }; 5099B9C51AB95111002F940B /* Rank */ = { isa = PBXGroup; children = ( @@ -1287,6 +1301,7 @@ 502AE5541AB93215005BD199 /* ProfileFooterCell.xib in Resources */, 50CDBE4A1ACBAD3200459CE0 /* ChatLeftImageCell.xib in Resources */, 0A90187F1B01152800AE4B7F /* ProfileSocialAccountCell.xib in Resources */, + 508F8FC91B0161EF00461B0B /* ProfileSeparationLineCell.xib in Resources */, 50894CF61AEA4A01000981AF /* SettingsUserCell.xib in Resources */, 508D17481ACCF4710092D666 /* ChatLeftAudioCell.xib in Resources */, 0A8F54B61AB67D11004AD60E /* Main.storyboard in Resources */, @@ -1409,6 +1424,7 @@ 5023DE331AB688F600B3EE96 /* UIColor+Yep.swift in Sources */, 503315971AC1017E0008A209 /* ChatLeftTextCell.swift in Sources */, 0A8F54B11AB67D11004AD60E /* AppDelegate.swift in Sources */, + 508F8FC81B0161EF00461B0B /* ProfileSeparationLineCell.swift in Sources */, 508D174C1ACCF49B0092D666 /* ChatRightAudioCell.swift in Sources */, 502AE53D1AB87C0D005BD199 /* YepUserDefaults.swift in Sources */, 50EB8CC41AE89F12001AC1EE /* ChatRightVideoCell.swift in Sources */, diff --git a/Yep/ViewControllers/Profile/ProfileViewController.swift b/Yep/ViewControllers/Profile/ProfileViewController.swift index d10fb321..e9d72df7 100644 --- a/Yep/ViewControllers/Profile/ProfileViewController.swift +++ b/Yep/ViewControllers/Profile/ProfileViewController.swift @@ -96,6 +96,7 @@ class ProfileViewController: CustomNavigationBarViewController { let footerCellIdentifier = "ProfileFooterCell" let sectionHeaderIdentifier = "ProfileSectionHeaderReusableView" let sectionFooterIdentifier = "ProfileSectionFooterReusableView" + let separationLineCellIdentifier = "ProfileSeparationLineCell" let socialAccountCellIdentifier = "ProfileSocialAccountCell" lazy var collectionViewWidth: CGFloat = { @@ -103,7 +104,7 @@ class ProfileViewController: CustomNavigationBarViewController { }() lazy var sectionLeftEdgeInset: CGFloat = { return YepConfig.Profile.leftEdgeInset }() lazy var sectionRightEdgeInset: CGFloat = { return YepConfig.Profile.rightEdgeInset }() - lazy var sectionBottomEdgeInset: CGFloat = { return 15 }() + lazy var sectionBottomEdgeInset: CGFloat = { return 0 }() let introductionText = "I would like to learn Design or Speech, I can teach you iOS Dev in return. 😃" @@ -126,6 +127,7 @@ class ProfileViewController: CustomNavigationBarViewController { profileCollectionView.registerNib(UINib(nibName: skillCellIdentifier, bundle: nil), forCellWithReuseIdentifier: skillCellIdentifier) profileCollectionView.registerNib(UINib(nibName: headerCellIdentifier, bundle: nil), forCellWithReuseIdentifier: headerCellIdentifier) profileCollectionView.registerNib(UINib(nibName: footerCellIdentifier, bundle: nil), forCellWithReuseIdentifier: footerCellIdentifier) + profileCollectionView.registerNib(UINib(nibName: separationLineCellIdentifier, bundle: nil), forCellWithReuseIdentifier: separationLineCellIdentifier) profileCollectionView.registerNib(UINib(nibName: socialAccountCellIdentifier, bundle: nil), forCellWithReuseIdentifier: socialAccountCellIdentifier) profileCollectionView.registerNib(UINib(nibName: sectionHeaderIdentifier, bundle: nil), forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withReuseIdentifier: sectionHeaderIdentifier) profileCollectionView.registerClass(UICollectionReusableView.self, forSupplementaryViewOfKind: UICollectionElementKindSectionFooter, withReuseIdentifier: sectionFooterIdentifier) @@ -315,12 +317,13 @@ extension ProfileViewController: UICollectionViewDataSource, UICollectionViewDel case Footer case Master case Learning + case SeparationLine case SocialAccount } func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int { - return 5 + return 6 } func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { @@ -359,6 +362,9 @@ extension ProfileViewController: UICollectionViewDataSource, UICollectionViewDel case ProfileSection.Footer.rawValue: return 1 + + case ProfileSection.SeparationLine.rawValue: + return 1 case ProfileSection.SocialAccount.rawValue: return 3 @@ -436,6 +442,11 @@ extension ProfileViewController: UICollectionViewDataSource, UICollectionViewDel cell.introductionLabel.text = introductionText return cell + + case ProfileSection.SeparationLine.rawValue: + let cell = collectionView.dequeueReusableCellWithReuseIdentifier(separationLineCellIdentifier, forIndexPath: indexPath) as! ProfileSeparationLineCell + + return cell case ProfileSection.SocialAccount.rawValue: @@ -492,16 +503,19 @@ extension ProfileViewController: UICollectionViewDataSource, UICollectionViewDel return UIEdgeInsets(top: 0, left: 0, bottom: sectionBottomEdgeInset, right: 0) case ProfileSection.Master.rawValue: - return UIEdgeInsets(top: 0, left: sectionLeftEdgeInset, bottom: sectionBottomEdgeInset, right: sectionRightEdgeInset) + return UIEdgeInsets(top: 0, left: sectionLeftEdgeInset, bottom: 15, right: sectionRightEdgeInset) case ProfileSection.Learning.rawValue: return UIEdgeInsets(top: 0, left: sectionLeftEdgeInset, bottom: sectionBottomEdgeInset, right: sectionRightEdgeInset) case ProfileSection.Footer.rawValue: - return UIEdgeInsets(top: 0, left: 0, bottom: sectionBottomEdgeInset, right: 0) + return UIEdgeInsets(top: 20, left: 0, bottom: 20, right: 0) + case ProfileSection.SeparationLine.rawValue: + return UIEdgeInsets(top: 40, left: 0, bottom: 30, right: 0) + case ProfileSection.SocialAccount.rawValue: - return UIEdgeInsets(top: 0, left: sectionLeftEdgeInset, bottom: sectionBottomEdgeInset, right: sectionRightEdgeInset) + return UIEdgeInsets(top: 0, left: 0, bottom: sectionBottomEdgeInset, right: 0) default: return UIEdgeInsetsZero @@ -557,6 +571,9 @@ extension ProfileViewController: UICollectionViewDataSource, UICollectionViewDel case ProfileSection.Footer.rawValue: return CGSizeMake(collectionViewWidth, footerCellHeight) + + case ProfileSection.SeparationLine.rawValue: + return CGSizeMake(collectionViewWidth, 1) case ProfileSection.SocialAccount.rawValue: return CGSizeMake(collectionViewWidth, 40) @@ -568,11 +585,11 @@ extension ProfileViewController: UICollectionViewDataSource, UICollectionViewDel func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize { - if section == ProfileSection.Header.rawValue || section == ProfileSection.Footer.rawValue { - return CGSizeMake(collectionViewWidth, 0) + if section == ProfileSection.Master.rawValue || section == ProfileSection.Learning.rawValue { + return CGSizeMake(collectionViewWidth, 40) } else { - return CGSizeMake(collectionViewWidth, 40) + return CGSizeMake(collectionViewWidth, 0) } } diff --git a/Yep/Views/Cells/ProfileSeparationLine/ProfileSeparationLineCell.swift b/Yep/Views/Cells/ProfileSeparationLine/ProfileSeparationLineCell.swift new file mode 100644 index 00000000..fd62f30f --- /dev/null +++ b/Yep/Views/Cells/ProfileSeparationLine/ProfileSeparationLineCell.swift @@ -0,0 +1,41 @@ +// +// ProfileSeparationLineCell.swift +// Yep +// +// Created by NIX on 15/5/12. +// Copyright (c) 2015年 Catch Inc. All rights reserved. +// + +import UIKit + +class ProfileSeparationLineCell: UICollectionViewCell { + + var leftEdgeInset: CGFloat = YepConfig.Profile.leftEdgeInset + var rightEdgeInset: CGFloat = YepConfig.Profile.rightEdgeInset + var lineColor: UIColor = UIColor.grayColor() + + lazy var separationLineLayer: CAShapeLayer = { + let layer = CAShapeLayer() + layer.lineWidth = 1.0 / UIScreen.mainScreen().scale + layer.strokeColor = self.lineColor.CGColor + return layer + }() + + + override func awakeFromNib() { + super.awakeFromNib() + + layer.addSublayer(separationLineLayer) + } + + override func layoutSubviews() { + super.layoutSubviews() + + let path = UIBezierPath() + path.moveToPoint(CGPoint(x: leftEdgeInset, y: CGRectGetHeight(bounds) * 0.5)) + path.addLineToPoint(CGPoint(x: CGRectGetWidth(bounds) - rightEdgeInset, y: CGRectGetHeight(bounds) * 0.5)) + + separationLineLayer.path = path.CGPath + } + +} diff --git a/Yep/Views/Cells/ProfileSeparationLine/ProfileSeparationLineCell.xib b/Yep/Views/Cells/ProfileSeparationLine/ProfileSeparationLineCell.xib new file mode 100644 index 00000000..d399ebe0 --- /dev/null +++ b/Yep/Views/Cells/ProfileSeparationLine/ProfileSeparationLineCell.xib @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + +