ScholarQuill logoScholarQuillUniversity Notes
  • Notes
  • Past Papers
  • Blogs
  • Todo
Login
ScholarQuill logoScholarQuillUniversity Notes
Login
NotesPast PapersBlogsTodo
More
SubjectsDiscussionCGPA CalculatorGPA CalculatorStudent PortalCourse Outline
About
About usPrivacy PolicyReportContact
Notes
Past Papers
Blogs
Todo
Analytics
    Current Subject
    🧩
    Mobile Application Development 2
    COMP4126
    Progress0 / 38 topics
    Topics
    1. Creating an iOS App: Understanding Xcode2. Using the Xcode interface builder and objects library3. Understanding view hierarchy and creating a custom app icon4. Outlets, Actions, and Views: Understanding outlets and actions5. Using text fields, buttons, labels, web views, and page controllers6. Using views with subviews and creating views using code7. Using View Controllers: Working with the single view template8. Exploring the app delegate and adding new view controllers9. Transitioning between multiple view controllers using animations10. Application Templates: Tabbar and master detail templates11. The iOS Keyboard: Customizing for different inputs12. Adjusting text field behaviors and dismissing the keyboard13. Detecting keyboard activities with notification center14. Using scroll view and responding to keyboard activities programmatically15. Working with Different iOS Devices (iPhone & iPad): Detecting device hardware16. Dynamically adjusting graphical layouts and creating universal apps17. Using Table Views: Understanding UITableView and UITableViewCell18. Working with UITableView data source and delegate19. Master detail template, drill-down menus, and navigation20. Using property lists for data persistence and creating multi-section tables21. Supporting Screen Rotations: Portrait and landscape modes22. Handling device rotation and forcing specific orientation23. Dynamically adjusting layouts based on rotation24. Working with Databases: Importing sqlite3 and creating a database25. Writing tables, inserting records, and bundling a database with your app26. Checking for database existence and reading/displaying data27. Using Animations & Video: NSTimer class and object transformations28. Rotation, scaling, translation, animating image arrays, and playing video29. Accessing Integrated iOS Apps: Email, Safari, and SMS30. Working with camera and photo library31. Using Web Services: Consuming and parsing XML and JSON32. Integrating Twitter and Facebook with iOS apps33. Working with iOS Maps and Location Services: MapKit and MKMapView34. Getting and displaying user location and directional information35. Displaying map annotations, disclosure buttons, and reverse geocoding36. Working with iCloud37. Working with the Accelerometer: Gyroscope and accelerometer38. Outputting sensor data and using the Shake API
    COMP4126›Rotation, scaling, translation, animating image arrays, and playing video
    Mobile Application Development 2Topic 28 of 38

    Rotation, scaling, translation, animating image arrays, and playing video

    3 minread
    566words
    Beginnerlevel

    🎬 Rotation, Scaling, Translation, Image Animations & Video Playback (iOS – Xcode)


    ✅ 1. Definition

    🔹 Object Transformations

    Object transformations are techniques used to change the appearance or position of UI elements such as views or images.

    They include:

    • 🔄 Rotation (turning)
    • 🔍 Scaling (resize)
    • ➡️ Translation (moving)

    🔹 Animation

    Animation is the process of making UI changes smooth over time instead of instantly.


    🔹 Image Array Animation

    Displaying multiple images in sequence to create a frame-by-frame animation.


    🔹 Video Playback

    Playing video files inside an iOS app using frameworks like AVFoundation or AVKit.


    🧠 2. Key Concepts

    🔹 CGAffineTransform

    Used to apply:

    • Rotation
    • Scaling
    • Translation

    🔹 UIView Animation

    Used for smooth transitions.

    🔹 UIImage Animation

    Used for frame-based image sequences.

    🔹 AVPlayer

    Used for video playback.


    🔄 3. Object Transformations


    🔹 1. Translation (Move Object)

    👉 Moves an object horizontally or vertically

    view.transform = CGAffineTransform(translationX: 50, y: 0)
    

    🔹 2. Scaling (Resize Object)

    👉 Increases or decreases size

    view.transform = CGAffineTransform(scaleX: 2.0, y: 2.0)
    

    🔹 3. Rotation (Rotate Object)

    👉 Rotates object around center

    view.transform = CGAffineTransform(rotationAngle: .pi / 4)
    

    👉 (π/4 = 45 degrees)


    🔹 4. Combined Transform

    view.transform =
        CGAffineTransform(translationX: 50, y: 50)
            .rotated(by: .pi / 4)
            .scaledBy(x: 1.5, y: 1.5)
    

    🎞️ 4. Animating Images (Image Array Animation)


    🔹 Step 1: Set Image Array

    imageView.animationImages = [
        UIImage(named: "img1")!,
        UIImage(named: "img2")!,
        UIImage(named: "img3")!
    ]
    

    🔹 Step 2: Set Duration

    imageView.animationDuration = 1.0
    

    🔹 Step 3: Start Animation

    imageView.startAnimating()
    

    🔹 Step 4: Stop Animation

    imageView.stopAnimating()
    

    📊 Image Animation Flow

    Image1 → Image2 → Image3 → Loop (Animation)
    

    🎬 5. Video Playback in iOS


    🔹 Using AVKit (Recommended)

    Step 1: Import Framework

    import AVKit
    import AVFoundation
    

    🔹 Step 2: Load Video

    let videoURL = URL(string: "https://example.com/video.mp4")!
    let player = AVPlayer(url: videoURL)
    

    🔹 Step 3: Create Player Controller

    let playerViewController = AVPlayerViewController()
    playerViewController.player = player
    

    🔹 Step 4: Play Video

    present(playerViewController, animated: true) {
        player.play()
    }
    

    📊 6. Video Playback Flow

    Video URL → AVPlayer → AVPlayerViewController → Play Video
    

    💡 7. Example App

    🎯 Media App

    • Image animation:

      • Moving slideshow
    • Video playback:

      • Play tutorial videos
    • Object animation:

      • Rotating icons

    📌 8. Important Rules / Tips

    • Use UIView.animate for smooth transformations
    • Use UIImageView animation for frame-based effects
    • Always stop animations when not needed
    • Use AVKit for easy video playback
    • Avoid heavy animations on main thread

    ⚠️ 9. Common Mistakes

    • ❌ Not importing AVKit/AVFoundation
    • ❌ Missing image assets for animation
    • ❌ Forgetting to start animation
    • ❌ Wrong rotation values (radians confusion)
    • ❌ Blocking UI during video playback

    🧠 10. Best Practices

    • Combine animations for better UI experience
    • Use vector-based transforms for performance
    • Keep animations short and smooth
    • Use AVPlayer for modern video apps
    • Optimize image assets for animation

    📝 11. Likely Exam Questions

    1. What is CGAffineTransform?
    2. Explain rotation, scaling, and translation.
    3. How do you animate images in iOS?
    4. Write code for image array animation.
    5. What is AVPlayer used for?
    6. How do you play a video in iOS?
    7. Differentiate image animation and video playback.
    8. What is UIView animation used for?

    📚 12. Quick Revision Summary

    • Transformations:

      • Translation → move
      • Scaling → resize
      • Rotation → turn
    • Image animation:

      • Uses UIImageView
      • Sequence of images
    • Video playback:

      • Uses AVKit + AVPlayer
    • Used in:

      • Games
      • Media apps
      • UI effects

    Previous topic 27
    Using Animations & Video: NSTimer class and object transformations
    Next topic 29
    Accessing Integrated iOS Apps: Email, Safari, and SMS

    Past Papers

    Open this section to load past papers

    Click on Show Past Papers to see past papers.
    On This Page
      Reading Stats
      Est. reading time3 min
      Word count566
      Code examples0
      DifficultyBeginner