APNG inside iOS app
I just released a framework to load and display APNG files for iOS.
You could just load an APNG image with the same pattern of UIImage
and UIImageView
like this by using it:
let image = APNGImage(name: "your_apng_image")
let imageView = APNGImageView(image: image)
imageView.startAnimating()
view.addSubview(imageView)
For more information, you can find it here: https://github.com/onevcat/APNGKit
Loading GIFs in iOS
The UIImageView
class provides the easiest way for developers to implement animations. All you need to do is to create an UIImageView
object with a series of images for animating.
Example
// Load images
NSArray *imageNames = @[@"win_1.png", @"win_2.png", @"win_3.png"];
NSMutableArray *images = [[NSMutableArray alloc] init];
for (int i = 0; i < imageNames.count; i++) {
[images addObject:[UIImage imageNamed:[imageNames objectAtIndex:i]]];
}
// Normal Animation
UIImageView *animationImageView = [[UIImageView alloc] initWithFrame:CGRectMake(60, 95, 86, 193)];
animationImageView.animationImages = images;
animationImageView.animationDuration = 0.5;
[self.view addSubview:animationImageView];
[animationImageView startAnimating];
Load two AVPlayers with one video
It is very simple:
Init the first player:
AVAsset *asset = [AVAsset assetWithURL:URL];
AVPlayerItem *playerItem = [AVPlayerItem playerItemWithAsset:asset];
AVPlayer *player = [AVPlayer playerWithPlayerItem:playerItem];
AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:player];
And the second player in the same way, BUT, use the same asset from the first one.
I have verified, it works.
There is all the info you need on the Apple page:
https://developer.apple.com/library/mac/documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/02_Playback.html
This abstraction means that you can play a given asset using different
players simultaneously
this quote is from this page.
Related Topics
iOS Google Maps Sdk Gmsmarker Positioning
Can't Build an App for Distribution After Joining Existing Enterprise Developer Program
Uiactivityviewcontroller => Launchservices: Invalidationhandler Called
How to Request Photo Gallery Permissions in iOS a Second Time
Submit Watchkit Provisioning Error
How to Post Data Using Afnetworking 2.0
Phonegap Notification.Alert Not Working
Stick UItableview Header View to Top When Creating Header in Storyboard
How to Get Nsnumberformatter Currency Style from Isocurrencycodes
Calculate The Range of Visible Text in UIlabel
Calculate Controlpoints While Drawing in iOS
Core Data Nstimeinterval Using an Accessor Directly Is Buggy
How to Animate Uilabel's Textcolor Change
Customize Google Maps Blue Dot for Current Location
API Call Error in Xcode 7/iOS 9 (How to Setup App Transport Security in Plist)