From c19250237414d474a296e7cda38fc798ed42c1d3 Mon Sep 17 00:00:00 2001 From: kevinzhow Date: Tue, 5 May 2015 15:49:32 +0800 Subject: [PATCH] refine waver and sampleview --- .../Conversation/ConversationViewController.swift | 2 ++ Yep/Views/AudioWaves/SampleView.swift | 2 +- Yep/Views/AudioWaves/YepWaverView.swift | 12 +++++++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Yep/ViewControllers/Conversation/ConversationViewController.swift b/Yep/ViewControllers/Conversation/ConversationViewController.swift index 54b30301..3200f1ae 100644 --- a/Yep/ViewControllers/Conversation/ConversationViewController.swift +++ b/Yep/ViewControllers/Conversation/ConversationViewController.swift @@ -445,6 +445,7 @@ class ConversationViewController: UIViewController { // 先调整一下初次的 contentInset setConversaitonCollectionViewOriginalContentInset() + //以前的方法不能保证边界情况滚到底部 scrollToLastMessage() } @@ -1173,6 +1174,7 @@ extension ConversationViewController: UICollectionViewDataSource, UICollectionVi super.viewDidDisappear(animated) FayeService.sharedManager.delegate = nil timer.invalidate() + self.waverView.removeFromSuperview() } // MARK: UIScrollViewDelegate diff --git a/Yep/Views/AudioWaves/SampleView.swift b/Yep/Views/AudioWaves/SampleView.swift index 2fcfbee9..a0302ee9 100644 --- a/Yep/Views/AudioWaves/SampleView.swift +++ b/Yep/Views/AudioWaves/SampleView.swift @@ -72,7 +72,7 @@ class SampleView: UIView { for (index, percent) in enumerate(samples) { let x = CGFloat(index) * sampleWidth + sampleGap * CGFloat(index) - let sampleHeightMax = viewHeight * 0.8 + let sampleHeightMax = viewHeight * 0.7 var realSampleHeight = percent * viewHeight realSampleHeight = realSampleHeight < 1 ? 1 : realSampleHeight diff --git a/Yep/Views/AudioWaves/YepWaverView.swift b/Yep/Views/AudioWaves/YepWaverView.swift index aab504c1..095c6192 100644 --- a/Yep/Views/AudioWaves/YepWaverView.swift +++ b/Yep/Views/AudioWaves/YepWaverView.swift @@ -31,9 +31,19 @@ class YepWaverView: UIView { } private func setup() { - waver = Waver(frame: CGRectMake(0, CGRectGetHeight(self.bounds)/2.0 - 50.0, CGRectGetWidth(self.bounds), 100.0)) + waver = Waver(frame: CGRectMake(0, CGRectGetHeight(self.bounds)/2.0 - 50.0 - 40.0, CGRectGetWidth(self.bounds), 100.0)) self.backgroundColor = UIColor(white: 1.0, alpha: 0.9) + } + + override func willMoveToSuperview(newSuperview: UIView?) { + super.willMoveToSuperview(newSuperview) self.addSubview(waver) } + + override func removeFromSuperview() { + super.removeFromSuperview() + waver.removeFromSuperview() + } + }