需要 iOS 8 或更高版本和 Xcode 6.1+
Swift 支持使用动态框架,因此仅在 iOS > 8 时受支持。
要通过 CocoaPods 安装,请将以下行添加到您的 Podfile
中。
use_frameworks!
并且
pod "VideoSplash"
然后,运行以下命令
$ pod install
import VideoSplash
class ViewController: VideoSplashViewController {
override func viewDidLoad() {
super.viewDidLoad()
let url = NSURL.fileURLWithPath(NSBundle.mainBundle().pathForResource("test", ofType: "mp4")!)
self.videoFrame = view.frame
self.fillMode = .ResizeAspectFill
self.alwaysRepeat = true
self.sound = true
self.startTime = 12.0
self.duration = 4.0
self.alpha = 0.7
self.backgroundColor = UIColor.blackColor()
self.contentURL = url
self.restartForeground = true
}
}