Sitelet https://github.com/C4Labs/C4iOS/commit/016ed0e426db2e60e7ce9455058e98ac68aeee1c
Skip to content

Commit 016ed0e

Browse files
tnantokaalejandro-isaza
authored andcommitted
README: Rewrite example code in latest Swift syntax (#692)
1 parent cf2bb30 commit 016ed0e

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

‎README.md‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ ViewAnimation(duration: 0.5) {
4242
Whereas using UIKit + Core Animation you'd have to do something like this:
4343

4444
```swift
45-
UIView.animateWithDuration(0.5) {
45+
UIView.animate(withDuration: 0.5) {
4646
v.center = self.view.center
4747
}
4848

4949
CATransaction.begin()
50-
CATransaction.setValue(NSNumber(float: 0.5), forKey: kCATransactionAnimationDuration)
50+
CATransaction.setValue(0.5, forKey: kCATransactionAnimationDuration)
5151
if let shapeLayer = v.layer as? CAShapeLayer {
5252
shapeLayer.lineWidth = 5
5353
}
@@ -122,18 +122,18 @@ Using UIKit + AVFoundation, you'd have to construct the movie object from scratc
122122

123123
```swift
124124
func viewDidLoad() {
125-
guard let url = NSBundle.mainBundle().URLForResource("halo.mp4", withExtension: nil) else {
125+
guard let url = Bundle.main.url(forResource: "halo.mp4", withExtension: nil) else {
126126
fatalError("File not found")
127127
}
128128

129-
let asset = AVAsset(URL: url)
129+
let asset = AVAsset(url: url)
130130
let player = AVQueuePlayer(playerItem: AVPlayerItem(asset: asset))
131-
player.actionAtItemEnd = .Pause
131+
player.actionAtItemEnd = .pause
132132

133133
let movieLayer = AVPlayerLayer(player: player)
134-
movieLayer.videoGravity = AVLayerVideoGravityResize
134+
movieLayer.videoGravity = .resize
135135

136-
let tracks = asset.tracksWithMediaType(AVMediaTypeVideo)
136+
let tracks = asset.tracks(withMediaType: .video)
137137

138138
let movieTrack = tracks[0]
139139
let size = movieTrack.naturalSize

0 commit comments

Comments
 (0)