iet iv = self.view.viewwithTag (4)!
UIView.animate (withDuration : 2, animations: {
iv.transform = iv.transform.rotated(by: CGFloat (360))
}
let iv = self.view. viewwithTag (4)!
UIView.animate (withDuration: 2, animations: {
iv.frame.origin.x += 100
if iv.frame.origin.x > self.view.frame.size.width {
iv.frame.origin.x =
}
})
let iv = self.view.viewNithTag (4)!
UIView.animate (withDurat ion: 2, animations:{
iv.transform = CGAffineTransform (scalex: 0.8,y:0.8)
})
let iv = self.view. viewwithTag (4) !
UIView.animate (withDuration: 2, animations: {
iv.alpha = 0.1
})
import UIKit
import AVKit
class ViewController: UIViewController {
@IBAction func Play (_ sender : Any)
{
let path = Bundle.main. path (forResource: "test", ofType: "mov")
let url = URL (fileURLWithPath: path!)
let player = AVPlayer (url: url)
let playerViewController = AVPlayerViewController ()
playerViewcontroller.player = plaver
playerViewController.view.frame = CGRect (x: 20, y: 100, width:self.view.bounds.width - 40, height: 200)
self.addChild(playerViewController)
self.view.addSubview(playerViewController.view)
}
}
import UIKit
import AVKit
class ViewController: UIViewController {
@IBAction func NetworkPlay(_ sender: UIButton) {
let neturl = "http://bos.nj.bpc.baidu.com/tieba-smallvideo/117723c435014fb2dd9a5fd56a57cc369£6a0.mp4"
guard let networkurl = URL(string: neturl ) else { return }
let player = AVPlayer (url: networkUrl)
let playerViewController = AVPlayerViewController ()
playerViewController.player = player
self.present (playerViewController,animated: true,completion:nil)
}
}
import UIKit
import AVKit
import AVFoundation
classViewController: UIViewcontroller {
var playflag = false
var playerViewController = AVPlayerViewController ()
var soundPlayer : AVAudioPlayer!
override func viewDidLoad () {
super.viewDidLoad ()
let iv = self.view.viewwithTag (4)!as!UIImageView
let img = UI Image. animatedImageNamed (" Erame-", duration: 0.5)
iv.image = img
Timer.scheduledTimer (timeInterval: 2.0, target: self, selector:#selector(doTimer), userInfo: nil, repeats: true)
}
@objc func doTimer () {
let iv = self. view.viewwithTag (4) !
UIView.animate (withDuration: 2, animations: {
iv.transform = iv.transform. rotated (by: CGFloat (360))
}
})
@IBAction func onPlayAudio sender : UIButton) {
let title = sender.currentTitle
let path = Bundle.main.path(forResource: title, ofType: "mp3")
let url = URL (fileURLWithPath: path!)
soundPlaver = try? AVAudioPlayer (contentsof: url)
soundPlayer.play()
}
@IBAction func onPlayVideo (_ sender: UIButton) {
if !playFlag {
let path = Bunale.main.path (forResource: "rollinwd Id", ofType: "m4a"
let url = URL (fileURLWithPath: path!)
let player = AvPlayer (url: url)
player.play ()
playerViewcontroller.player = player
let buttonPosition = sender.frame
let x = buttonPosition .origin.x-200
let y = buttonPosition.origin.y-120
playerViewController.view. frame = CGRect (x: x, y: y , width:200, height: 112)
self.addChild (playerViewController)
self.view.addSubview (playerViewController.view)
playFlag = true
}
else {
playerViewController.view.removeFromSuperview()
playFlag = false
}
}
}
UIDeviceOrientationDidChangeNotification
NotificationCenter.default.addobserver(self,selector: #selector(receivedRotation(notification:)),name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil)
func receivedRotation(notification :NSNotification){
backgroundView.frame = CGRect(x: 0,y: 0,width: self.view.frame.size.width,height: self.view.frame.size.height)
}