add MediaControlView

This commit is contained in:
nixzhu
2015-05-07 01:59:25 +08:00
parent c99b3312e0
commit 73abd6da0b
3 changed files with 98 additions and 9 deletions
+4
View File
@@ -144,6 +144,7 @@
50CDBE461ACA9F2200459CE0 /* ImageCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50CDBE451ACA9F2200459CE0 /* ImageCache.swift */; };
50CDBE491ACBAD3200459CE0 /* ChatLeftImageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50CDBE471ACBAD3200459CE0 /* ChatLeftImageCell.swift */; };
50CDBE4A1ACBAD3200459CE0 /* ChatLeftImageCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 50CDBE481ACBAD3200459CE0 /* ChatLeftImageCell.xib */; };
50D4D0DB1AFA825B005AEB6F /* MediaControlView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50D4D0DA1AFA825B005AEB6F /* MediaControlView.swift */; };
50E114F41ABBF9CC00F13000 /* Models.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50E114F31ABBF9CC00F13000 /* Models.swift */; };
50E114F71ABBFA7000F13000 /* RLMSupport.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50E114F61ABBFA7000F13000 /* RLMSupport.swift */; };
50E114F91ABC137A00F13000 /* YepServiceSync.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50E114F81ABC137A00F13000 /* YepServiceSync.swift */; };
@@ -315,6 +316,7 @@
50CDBE451ACA9F2200459CE0 /* ImageCache.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ImageCache.swift; path = Caches/ImageCache.swift; sourceTree = "<group>"; };
50CDBE471ACBAD3200459CE0 /* ChatLeftImageCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ChatLeftImageCell.swift; path = Views/Cells/ChatLeftImage/ChatLeftImageCell.swift; sourceTree = "<group>"; };
50CDBE481ACBAD3200459CE0 /* ChatLeftImageCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = ChatLeftImageCell.xib; path = Views/Cells/ChatLeftImage/ChatLeftImageCell.xib; sourceTree = "<group>"; };
50D4D0DA1AFA825B005AEB6F /* MediaControlView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MediaControlView.swift; path = Views/Media/MediaControlView.swift; sourceTree = "<group>"; };
50E114F31ABBF9CC00F13000 /* Models.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Models.swift; path = Realm/Models.swift; sourceTree = "<group>"; };
50E114F61ABBFA7000F13000 /* RLMSupport.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RLMSupport.swift; path = Realm/RLMSupport.swift; sourceTree = "<group>"; };
50E114F81ABC137A00F13000 /* YepServiceSync.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = YepServiceSync.swift; path = Services/YepServiceSync.swift; sourceTree = "<group>"; };
@@ -1063,6 +1065,7 @@
isa = PBXGroup;
children = (
50EB8CCA1AEA1AC0001AC1EE /* MediaView.swift */,
50D4D0DA1AFA825B005AEB6F /* MediaControlView.swift */,
);
name = Media;
sourceTree = "<group>";
@@ -1330,6 +1333,7 @@
508D174C1ACCF49B0092D666 /* ChatRightAudioCell.swift in Sources */,
502AE53D1AB87C0D005BD199 /* YepUserDefaults.swift in Sources */,
50EB8CC41AE89F12001AC1EE /* ChatRightVideoCell.swift in Sources */,
50D4D0DB1AFA825B005AEB6F /* MediaControlView.swift in Sources */,
508D17471ACCF4710092D666 /* ChatLeftAudioCell.swift in Sources */,
50894D021AEA6433000981AF /* EditProfileLessInfoCell.swift in Sources */,
50894CFA1AEA54BA000981AF /* SettingsMoreCell.swift in Sources */,
+20 -9
View File
@@ -72,14 +72,14 @@
</connections>
</collectionView>
<toolbar opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Q0w-sM-iIR" customClass="MessageToolbar" customModule="Yep" customModuleProvider="target">
<rect key="frame" x="0.0" y="250" width="600" height="50"/>
<rect key="frame" x="0.0" y="396" width="600" height="44"/>
<items/>
</toolbar>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="g11-Ob-rEy" userLabel="More Message Types View">
<rect key="frame" x="0.0" y="300" width="600" height="300"/>
<rect key="frame" x="0.0" y="440" width="600" height="300"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="avI-im-eEZ" userLabel="Choose Photo Button" customClass="MessageTypeButton" customModule="Yep" customModuleProvider="target">
<rect key="frame" x="20" y="20" width="173" height="120"/>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="avI-im-eEZ" userLabel="Choose Photo Button" customClass="MessageTypeButton" customModule="Yep" customModuleProvider="target">
<rect key="frame" x="20" y="20" width="173" height="260"/>
<state key="normal">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
@@ -88,8 +88,8 @@
<userDefinedRuntimeAttribute type="string" keyPath="title" value="Choose photo"/>
</userDefinedRuntimeAttributes>
</button>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="HcA-7v-16m" userLabel="Take Photo Button" customClass="MessageTypeButton" customModule="Yep" customModuleProvider="target">
<rect key="frame" x="213" y="20" width="174" height="120"/>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="HcA-7v-16m" userLabel="Take Photo Button" customClass="MessageTypeButton" customModule="Yep" customModuleProvider="target">
<rect key="frame" x="213" y="20" width="174" height="260"/>
<state key="normal">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
@@ -98,8 +98,8 @@
<userDefinedRuntimeAttribute type="string" keyPath="title" value="Take photo"/>
</userDefinedRuntimeAttributes>
</button>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Hg3-Ss-sqD" userLabel="Add Location Button" customClass="MessageTypeButton" customModule="Yep" customModuleProvider="target">
<rect key="frame" x="407" y="20" width="173" height="120"/>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Hg3-Ss-sqD" userLabel="Add Location Button" customClass="MessageTypeButton" customModule="Yep" customModuleProvider="target">
<rect key="frame" x="407" y="20" width="173" height="260"/>
<state key="normal">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
@@ -120,6 +120,7 @@
<constraint firstItem="avI-im-eEZ" firstAttribute="height" secondItem="HcA-7v-16m" secondAttribute="height" id="apZ-ns-N9S"/>
<constraint firstItem="avI-im-eEZ" firstAttribute="top" secondItem="g11-Ob-rEy" secondAttribute="top" constant="20" id="b4S-GW-ghP"/>
<constraint firstAttribute="height" constant="300" id="faf-Xw-b0H"/>
<constraint firstAttribute="bottom" secondItem="avI-im-eEZ" secondAttribute="bottom" constant="20" id="sv1-0R-BYO"/>
<constraint firstItem="Hg3-Ss-sqD" firstAttribute="leading" secondItem="HcA-7v-16m" secondAttribute="trailing" constant="20" id="uSu-cr-saV"/>
<constraint firstItem="avI-im-eEZ" firstAttribute="leading" secondItem="g11-Ob-rEy" secondAttribute="leading" constant="20" id="uke-uY-P5h"/>
<constraint firstItem="Hg3-Ss-sqD" firstAttribute="height" secondItem="HcA-7v-16m" secondAttribute="height" id="xWM-E0-CPp"/>
@@ -133,7 +134,7 @@
<constraint firstItem="g11-Ob-rEy" firstAttribute="leading" secondItem="P6X-OT-hT5" secondAttribute="leading" id="B04-LV-qWQ"/>
<constraint firstItem="Q0w-sM-iIR" firstAttribute="leading" secondItem="P6X-OT-hT5" secondAttribute="leading" id="BYY-lE-CF8"/>
<constraint firstItem="o5R-dM-KPW" firstAttribute="leading" secondItem="P6X-OT-hT5" secondAttribute="leading" id="BjN-8c-WjM"/>
<constraint firstAttribute="bottom" secondItem="Q0w-sM-iIR" secondAttribute="bottom" constant="300" id="Sf8-1u-t01"/>
<constraint firstAttribute="bottom" secondItem="Q0w-sM-iIR" secondAttribute="bottom" constant="160" id="Sf8-1u-t01"/>
<constraint firstItem="g11-Ob-rEy" firstAttribute="top" secondItem="Q0w-sM-iIR" secondAttribute="bottom" id="UC0-RV-osX"/>
<constraint firstAttribute="trailing" secondItem="g11-Ob-rEy" secondAttribute="trailing" id="cB1-tg-2P7"/>
<constraint firstItem="o5R-dM-KPW" firstAttribute="top" secondItem="P6X-OT-hT5" secondAttribute="top" id="d3q-cT-PCM"/>
@@ -243,12 +244,22 @@
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="2Cb-zQ-dUZ" customClass="MediaControlView" customModule="Yep" customModuleProvider="target">
<rect key="frame" x="0.0" y="540" width="600" height="60"/>
<color key="backgroundColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="60" id="2CO-oT-53G"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<gestureRecognizers/>
<constraints>
<constraint firstItem="eW6-5y-wrX" firstAttribute="top" secondItem="k4j-Ub-3bn" secondAttribute="bottom" id="SD4-Rb-R2n"/>
<constraint firstItem="k4j-Ub-3bn" firstAttribute="top" secondItem="aNq-7S-JK2" secondAttribute="top" id="Zbg-wi-X7W"/>
<constraint firstAttribute="trailing" secondItem="2Cb-zQ-dUZ" secondAttribute="trailing" id="gVX-Fl-qnR"/>
<constraint firstItem="2Cb-zQ-dUZ" firstAttribute="leading" secondItem="aNq-7S-JK2" secondAttribute="leading" id="lDq-Nl-fPd"/>
<constraint firstItem="eW6-5y-wrX" firstAttribute="top" secondItem="2Cb-zQ-dUZ" secondAttribute="bottom" id="o3u-xh-Qwa"/>
<constraint firstItem="k4j-Ub-3bn" firstAttribute="leading" secondItem="aNq-7S-JK2" secondAttribute="leading" id="xJR-ze-vBa"/>
<constraint firstAttribute="trailing" secondItem="k4j-Ub-3bn" secondAttribute="trailing" id="xvH-sO-9MX"/>
</constraints>
+74
View File
@@ -0,0 +1,74 @@
//
// MediaControlView.swift
// Yep
//
// Created by NIX on 15/5/7.
// Copyright (c) 2015 Catch Inc. All rights reserved.
//
import UIKit
@IBDesignable
class MediaControlView: UIView {
lazy var timeLabel: UILabel = {
let label = UILabel()
label.textAlignment = .Center
label.font = UIFont(name: "HelveticaNeue-Light", size: 14)
label.textColor = UIColor.whiteColor()
label.text = "00:42"
return label
}()
lazy var playButton: UIButton = {
let button = UIButton()
button.setImage(UIImage(named: "icon_play"), forState: .Normal)
button.tintColor = UIColor.whiteColor()
button.contentEdgeInsets = UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 20)
button.addTarget(self, action: "playOrPause", forControlEvents: UIControlEvents.TouchUpInside)
return button
}()
lazy var shareButton: UIButton = {
let button = UIButton()
button.setImage(UIImage(named: "icon_more"), forState: .Normal)
button.tintColor = UIColor.whiteColor()
button.contentEdgeInsets = UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 20)
button.addTarget(self, action: "share", forControlEvents: UIControlEvents.TouchUpInside)
return button
}()
override func didMoveToSuperview() {
super.didMoveToSuperview()
makeUI()
}
func makeUI() {
addSubview(timeLabel)
addSubview(playButton)
addSubview(shareButton)
timeLabel.setTranslatesAutoresizingMaskIntoConstraints(false)
playButton.setTranslatesAutoresizingMaskIntoConstraints(false)
shareButton.setTranslatesAutoresizingMaskIntoConstraints(false)
let viewsDictionary = [
"timeLable": timeLabel,
"playButton": playButton,
"shareButton": shareButton,
]
let constraintsV = NSLayoutConstraint.constraintsWithVisualFormat("V:|[timeLable]|", options: NSLayoutFormatOptions(0), metrics: nil, views: viewsDictionary)
let constraintsH = NSLayoutConstraint.constraintsWithVisualFormat("H:|-20-[timeLable]-(>=0)-[playButton]-(>=0)-[shareButton]|", options: .AlignAllCenterY | .AlignAllTop | .AlignAllBottom, metrics: nil, views: viewsDictionary)
NSLayoutConstraint.activateConstraints(constraintsV)
NSLayoutConstraint.activateConstraints(constraintsH)
let playButtonConstraintCenterX = NSLayoutConstraint(item: playButton, attribute: .CenterX, relatedBy: .Equal, toItem: self, attribute: .CenterX, multiplier: 1.0, constant: 0)
NSLayoutConstraint.activateConstraints([playButtonConstraintCenterX])
}
}