ScholarQuill logoScholarQuillUniversity Notes
My Semester
Explore Notes
Past Papers12 New
Video CoursesNew
Search
Settings
Study Tools
GPA/CGPA Calculator
Schedule & To-Do
Student Portal
Contact
Contact
ScholarQuill logo
My Semester
Explore Notes
Past Papers12 New
Video CoursesNew
Search
Settings
GPA/CGPA Calculator
Schedule & To-Do
Student Portal
Contact
ScholarQuill logoScholarQuillUniversity Notes
Study PortalCOMP4126Rotation Scaling Trans…
Ctrl + K
Login
Explore
Search
Semester
Papers
CGPA
    COMP4126

    Mobile Application Development 2

    Progress0 / 38 done
    Topics38
    1Understanding Xcode2Using the Xcode interface builder and objects library3Understanding view hierarchy and creating a custom app icon
    4Understanding outlets and actions5Using text fields, buttons, labels, web views, and page controllers6Using views with subviews and creating views using code
    7Working with the single view template8Exploring the app delegate and adding new view controllers9Transitioning between multiple view controllers using animations
    10Tabbar and master detail templates
    11Customizing for different inputs12Adjusting text field behaviors and dismissing the keyboard13Detecting keyboard activities with notification center14Using scroll view and responding to keyboard activities programmatically
    15Detecting device hardware16Dynamically adjusting graphical layouts and creating universal apps
    17Understanding UITableView and UITableViewCell18Working with UITableView data source and delegate19Master detail template, drill-down menus, and navigation20Using property lists for data persistence and creating multi-section tables
    21Portrait and landscape modes22Handling device rotation and forcing specific orientation23Dynamically adjusting layouts based on rotation
    24Importing sqlite3 and creating a database25Writing tables, inserting records, and bundling a database with your app26Checking for database existence and reading/displaying data
    27NSTimer class and object transformations28Rotation, scaling, translation, animating image arrays, and playing video
    29Email, Safari, and SMS30Working with camera and photo library
    31Consuming and parsing XML and JSON32Integrating Twitter and Facebook with iOS apps
    33MapKit and MKMapView34Getting and displaying user location and directional information35Displaying map annotations, disclosure buttons, and reverse geocoding36Working with iCloud
    37Gyroscope and accelerometer38Outputting sensor data and using the Shake API
    3 min read
    Topic 28 of 38
    Topic Study Note Illustration
    28

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

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

    🎬 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 view and download past papers

    Click on Show Past Papers to load available exam papers.

    Reading Progress
    0%
    3mremaining
    566words
    Beginnerlevel
    On This Page

    No headings found

    Study Toolkit

    Subject Portal

    Mobile Application Development 2