Added tvOS example

This commit is contained in:
Isaac Overacker
2016-02-06 21:44:22 -08:00
parent dfe601aef0
commit b563875a3a
35 changed files with 1319 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
//
// AppDelegate.swift
// PINRemoteImage.tvOSExample
//
// Created by Isaac Overacker on 2/6/16.
//
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
return true
}
func applicationWillResignActive(application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
func applicationDidEnterBackground(application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}

View File

@@ -0,0 +1,12 @@
{
"images" : [
{
"idiom" : "tv",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@@ -0,0 +1,17 @@
{
"layers" : [
{
"filename" : "Front.imagestacklayer"
},
{
"filename" : "Middle.imagestacklayer"
},
{
"filename" : "Back.imagestacklayer"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@@ -0,0 +1,12 @@
{
"images" : [
{
"idiom" : "tv",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@@ -0,0 +1,12 @@
{
"images" : [
{
"idiom" : "tv",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@@ -0,0 +1,12 @@
{
"images" : [
{
"idiom" : "tv",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@@ -0,0 +1,17 @@
{
"layers" : [
{
"filename" : "Front.imagestacklayer"
},
{
"filename" : "Middle.imagestacklayer"
},
{
"filename" : "Back.imagestacklayer"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@@ -0,0 +1,12 @@
{
"images" : [
{
"idiom" : "tv",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@@ -0,0 +1,12 @@
{
"images" : [
{
"idiom" : "tv",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@@ -0,0 +1,26 @@
{
"assets" : [
{
"size" : "1280x768",
"idiom" : "tv",
"filename" : "App Icon - Large.imagestack",
"role" : "primary-app-icon"
},
{
"size" : "400x240",
"idiom" : "tv",
"filename" : "App Icon - Small.imagestack",
"role" : "primary-app-icon"
},
{
"size" : "1920x720",
"idiom" : "tv",
"filename" : "Top Shelf Image.imageset",
"role" : "top-shelf-image"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@@ -0,0 +1,12 @@
{
"images" : [
{
"idiom" : "tv",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@@ -0,0 +1,15 @@
{
"images" : [
{
"orientation" : "landscape",
"idiom" : "tv",
"extent" : "full-screen",
"minimum-system-version" : "9.0",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@@ -0,0 +1,13 @@
{
"images" : [
{
"idiom" : "tv",
"filename" : "white-pinterest-logo@1x.png",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -0,0 +1,248 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder.AppleTV.Storyboard" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="AppleTV" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="49e-Tb-3d3">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
</dependencies>
<scenes>
<!--WebP-->
<scene sceneID="hNz-n2-bh7">
<objects>
<viewController id="9pv-A4-QxB" customClass="WebPViewController" customModule="PINRemoteImage_tvOSExample" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Ia1-K6-d13"/>
<viewControllerLayoutGuide type="bottom" id="4ug-Mw-9AY"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="tsR-hK-woN">
<rect key="frame" x="0.0" y="0.0" width="1920" height="1080"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Aav-0m-Omh">
<rect key="frame" x="20" y="0.0" width="1880" height="1080"/>
</imageView>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="Aav-0m-Omh" firstAttribute="top" secondItem="Ia1-K6-d13" secondAttribute="bottom" id="6Ht-Zl-b4M"/>
<constraint firstItem="Aav-0m-Omh" firstAttribute="leading" secondItem="tsR-hK-woN" secondAttribute="leadingMargin" id="eMM-4Q-FP4"/>
<constraint firstItem="4ug-Mw-9AY" firstAttribute="top" secondItem="Aav-0m-Omh" secondAttribute="bottom" id="gHg-Zb-fcQ"/>
<constraint firstAttribute="trailingMargin" secondItem="Aav-0m-Omh" secondAttribute="trailing" id="rGZ-K8-3DN"/>
</constraints>
</view>
<tabBarItem key="tabBarItem" title="WebP" id="acW-dT-cKf"/>
<connections>
<outlet property="imageView" destination="Aav-0m-Omh" id="iNg-er-rJA"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="W5J-7L-Pyd" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2246" y="-640"/>
</scene>
<!--Progressive-->
<scene sceneID="wg7-f3-ORb">
<objects>
<viewController id="8rJ-Kc-sve" customClass="ProgressiveViewController" customModule="PINRemoteImage_tvOSExample" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="L7p-HK-0SC"/>
<viewControllerLayoutGuide type="bottom" id="Djb-ko-YwX"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="QS5-Rx-YEW">
<rect key="frame" x="0.0" y="0.0" width="1920" height="1080"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="jKD-su-KpY">
<rect key="frame" x="20" y="0.0" width="1880" height="1080"/>
</imageView>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="Djb-ko-YwX" firstAttribute="top" secondItem="jKD-su-KpY" secondAttribute="bottom" id="Ehc-dh-8AV"/>
<constraint firstItem="jKD-su-KpY" firstAttribute="top" secondItem="L7p-HK-0SC" secondAttribute="bottom" id="H9a-Md-Fqf"/>
<constraint firstItem="jKD-su-KpY" firstAttribute="leading" secondItem="QS5-Rx-YEW" secondAttribute="leadingMargin" id="nA3-Fb-vaH"/>
<constraint firstAttribute="trailingMargin" secondItem="jKD-su-KpY" secondAttribute="trailing" id="y2q-wd-1pa"/>
</constraints>
</view>
<tabBarItem key="tabBarItem" title="Progressive" id="cPa-gy-q4n"/>
<connections>
<outlet property="imageView" destination="jKD-su-KpY" id="vT0-bQ-ePi"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="4Nw-L8-lE0" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2246" y="624"/>
</scene>
<!--Processing-->
<scene sceneID="00S-Bh-Ln3">
<objects>
<viewController id="p0y-1w-OIp" customClass="ProcessingViewController" customModule="PINRemoteImage_tvOSExample" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="UvO-gc-aaa"/>
<viewControllerLayoutGuide type="bottom" id="gHB-yh-03b"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="7kj-Gb-y7V">
<rect key="frame" x="0.0" y="0.0" width="1920" height="1080"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="cjj-0G-D8f">
<rect key="frame" x="860" y="390" width="200" height="300"/>
<constraints>
<constraint firstAttribute="width" constant="200" id="D3U-lY-gNu"/>
<constraint firstAttribute="height" constant="300" id="W9z-AN-hXr"/>
</constraints>
</imageView>
</subviews>
<constraints>
<constraint firstItem="cjj-0G-D8f" firstAttribute="centerY" secondItem="7kj-Gb-y7V" secondAttribute="centerY" id="5ad-71-X77"/>
<constraint firstItem="cjj-0G-D8f" firstAttribute="centerX" secondItem="7kj-Gb-y7V" secondAttribute="centerX" id="zvw-o2-dgr"/>
</constraints>
</view>
<tabBarItem key="tabBarItem" title="Processing" id="AHI-11-4NI"/>
<connections>
<outlet property="imageView" destination="cjj-0G-D8f" id="Dnq-T7-a9N"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="t1k-u4-CuB" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2246" y="1812"/>
</scene>
<!--Degraded-->
<scene sceneID="hPb-Wi-Vud">
<objects>
<viewController id="jVL-yP-ZE6" customClass="DegradedViewController" customModule="PINRemoteImage_tvOSExample" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="k0o-8j-1QQ"/>
<viewControllerLayoutGuide type="bottom" id="iHy-ln-CfP"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="MWg-Fv-za0">
<rect key="frame" x="0.0" y="0.0" width="1920" height="1080"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="zov-jb-gbf">
<rect key="frame" x="20" y="0.0" width="1880" height="1080"/>
</imageView>
</subviews>
<constraints>
<constraint firstAttribute="trailingMargin" secondItem="zov-jb-gbf" secondAttribute="trailing" id="CIX-FL-MKZ"/>
<constraint firstItem="zov-jb-gbf" firstAttribute="top" secondItem="k0o-8j-1QQ" secondAttribute="bottom" id="jWP-yZ-vtS"/>
<constraint firstItem="zov-jb-gbf" firstAttribute="leading" secondItem="MWg-Fv-za0" secondAttribute="leadingMargin" id="tqj-4c-oTk"/>
<constraint firstItem="iHy-ln-CfP" firstAttribute="top" secondItem="zov-jb-gbf" secondAttribute="bottom" id="vSV-Qj-urs"/>
</constraints>
</view>
<tabBarItem key="tabBarItem" title="Degraded" id="YYV-Ex-0cV"/>
<connections>
<outlet property="imageView" destination="zov-jb-gbf" id="X89-25-Tfs"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dZT-bH-OGg" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2246" y="2972"/>
</scene>
<!--Collection-->
<scene sceneID="syr-6P-Mxj">
<objects>
<collectionViewController id="YZW-JZ-Khs" customClass="CollectionViewController" customModule="PINRemoteImage_tvOSExample" customModuleProvider="target" sceneMemberID="viewController">
<collectionView key="view" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" id="gy0-2B-Oyn">
<rect key="frame" x="0.0" y="0.0" width="1920" height="1080"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<collectionViewFlowLayout key="collectionViewLayout" scrollDirection="horizontal" minimumLineSpacing="10" minimumInteritemSpacing="10" id="r1D-cL-AFs">
<size key="itemSize" width="600" height="600"/>
<size key="headerReferenceSize" width="0.0" height="0.0"/>
<size key="footerReferenceSize" width="0.0" height="0.0"/>
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
</collectionViewFlowLayout>
<cells>
<collectionViewCell opaque="NO" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="Cell" id="GhF-Kg-vfX" customClass="CollectionViewCell" customModule="PINRemoteImage_tvOSExample" customModuleProvider="target">
<rect key="frame" x="0.0" y="240" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Ste-pS-Dez" userLabel="ImageView">
<rect key="frame" x="8" y="8" width="584" height="584"/>
</imageView>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
<constraints>
<constraint firstItem="Ste-pS-Dez" firstAttribute="leading" secondItem="GhF-Kg-vfX" secondAttribute="leadingMargin" id="8ax-ku-EyF"/>
<constraint firstAttribute="trailingMargin" secondItem="Ste-pS-Dez" secondAttribute="trailing" id="Tf1-zd-VHL"/>
<constraint firstAttribute="bottomMargin" secondItem="Ste-pS-Dez" secondAttribute="bottom" id="UJT-bg-54a"/>
<constraint firstItem="Ste-pS-Dez" firstAttribute="top" secondItem="GhF-Kg-vfX" secondAttribute="topMargin" id="vsu-LI-UdH"/>
</constraints>
<connections>
<outlet property="imageView" destination="Ste-pS-Dez" id="T4r-Rq-b8N"/>
</connections>
</collectionViewCell>
</cells>
<connections>
<outlet property="dataSource" destination="YZW-JZ-Khs" id="mAG-9k-kMc"/>
<outlet property="delegate" destination="YZW-JZ-Khs" id="4lY-Gw-UaX"/>
</connections>
</collectionView>
<tabBarItem key="tabBarItem" title="Collection" id="7Vr-Ja-dGW"/>
<connections>
<outlet property="collectionView" destination="gy0-2B-Oyn" id="sxp-Ag-uMe"/>
</connections>
</collectionViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="lP3-DU-iqB" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2246" y="4151"/>
</scene>
<!--GIF-->
<scene sceneID="726-cb-Rit">
<objects>
<viewController id="BQc-Na-RDJ" customClass="GIFViewController" customModule="PINRemoteImage_tvOSExample" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="6W2-gt-DLK"/>
<viewControllerLayoutGuide type="bottom" id="vIm-pT-F5J"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="SLb-ae-8uE">
<rect key="frame" x="0.0" y="0.0" width="1920" height="1080"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="axH-c2-F7Z" customClass="FLAnimatedImageView">
<rect key="frame" x="20" y="0.0" width="1880" height="1080"/>
</imageView>
</subviews>
<constraints>
<constraint firstItem="vIm-pT-F5J" firstAttribute="top" secondItem="axH-c2-F7Z" secondAttribute="bottom" id="CI5-QQ-OnO"/>
<constraint firstAttribute="trailingMargin" secondItem="axH-c2-F7Z" secondAttribute="trailing" id="VoC-0X-fGh"/>
<constraint firstItem="axH-c2-F7Z" firstAttribute="top" secondItem="6W2-gt-DLK" secondAttribute="bottom" id="s40-gD-Edf"/>
<constraint firstItem="axH-c2-F7Z" firstAttribute="leading" secondItem="SLb-ae-8uE" secondAttribute="leadingMargin" id="wLP-9a-Bo2"/>
</constraints>
</view>
<tabBarItem key="tabBarItem" title="GIF" id="qwD-HD-45H"/>
<connections>
<outlet property="animatedImageView" destination="axH-c2-F7Z" id="tFA-HQ-p6d"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="X0Q-CC-kca" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2246" y="5336"/>
</scene>
<!--Tab Bar Controller-->
<scene sceneID="yl2-sM-qoP">
<objects>
<tabBarController id="49e-Tb-3d3" sceneMemberID="viewController">
<nil key="simulatedBottomBarMetrics"/>
<tabBar key="tabBar" contentMode="scaleToFill" id="W28-zg-YXA">
<rect key="frame" x="0.0" y="0.0" width="1920" height="120"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</tabBar>
<connections>
<segue destination="9pv-A4-QxB" kind="relationship" relationship="viewControllers" id="u7Y-xg-7CH"/>
<segue destination="8rJ-Kc-sve" kind="relationship" relationship="viewControllers" id="lzU-1b-eKA"/>
<segue destination="p0y-1w-OIp" kind="relationship" relationship="viewControllers" id="viv-6a-uMT"/>
<segue destination="jVL-yP-ZE6" kind="relationship" relationship="viewControllers" id="RVd-en-LvT"/>
<segue destination="YZW-JZ-Khs" kind="relationship" relationship="viewControllers" id="mL1-l4-3CC"/>
<segue destination="BQc-Na-RDJ" kind="relationship" relationship="viewControllers" id="dBN-fC-hOf"/>
</connections>
</tabBarController>
<placeholder placeholderIdentifier="IBFirstResponder" id="HuB-VB-40B" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="0.0" y="0.0"/>
</scene>
</scenes>
</document>

View File

@@ -0,0 +1,20 @@
//
// CollectionViewCell.swift
// PINRemoteImage.tvOSExample
//
// Created by Isaac Overacker on 2/6/16.
//
//
import UIKit
class CollectionViewCell: UICollectionViewCell {
@IBOutlet weak var imageView: UIImageView!
override func prepareForReuse() {
super.prepareForReuse()
self.imageView.image = nil
}
}

View File

@@ -0,0 +1,65 @@
//
// CollectionViewController.swift
// PINRemoteImage.tvOSExample
//
// Created by Isaac Overacker on 2/6/16.
//
//
import UIKit
import PINRemoteImage
private let reuseIdentifier = "Cell"
class CollectionViewController: UICollectionViewController {
let kittenURLs = [
NSURL(string: "https://s-media-cache-ak0.pinimg.com/736x/92/5d/5a/925d5ac74db0dcfabc238e1686e31d16.jpg"),
NSURL(string: "https://s-media-cache-ak0.pinimg.com/736x/ff/b3/ae/ffb3ae40533b7f9463cf1c04d7ab69d1.jpg"),
NSURL(string: "https://s-media-cache-ak0.pinimg.com/736x/e4/b7/7c/e4b77ca06e1d4a401b1a49d7fadd90d9.jpg"),
NSURL(string: "https://s-media-cache-ak0.pinimg.com/736x/46/e1/59/46e159d76b167ed9211d662f95e7bf6f.jpg"),
NSURL(string: "https://s-media-cache-ak0.pinimg.com/736x/7a/72/77/7a72779329942c06f888c148eb8d7e34.jpg"),
NSURL(string: "https://s-media-cache-ak0.pinimg.com/736x/60/21/8f/60218ff43257fb3b6d7c5b888f74a5bf.jpg"),
NSURL(string: "https://s-media-cache-ak0.pinimg.com/736x/90/e8/e4/90e8e47d53e71e0d97691dd13a5617fb.jpg"),
NSURL(string: "https://s-media-cache-ak0.pinimg.com/736x/96/ae/31/96ae31fbc52d96dd3308d2754a6ca37e.jpg"),
NSURL(string: "https://s-media-cache-ak0.pinimg.com/736x/9b/7b/99/9b7b99ff63be31bba8f9863724b3ebbc.jpg"),
NSURL(string: "https://s-media-cache-ak0.pinimg.com/736x/80/23/51/802351d953dd2a8b232d0da1c7ca6880.jpg"),
NSURL(string: "https://s-media-cache-ak0.pinimg.com/736x/f5/c4/f0/f5c4f04fa2686338dc3b08420d198484.jpg"),
NSURL(string: "https://s-media-cache-ak0.pinimg.com/736x/2b/06/4f/2b064f3e0af984a556ac94b251ff7060.jpg"),
NSURL(string: "https://s-media-cache-ak0.pinimg.com/736x/17/1f/c0/171fc02398143269d8a507a15563166a.jpg"),
NSURL(string: "https://s-media-cache-ak0.pinimg.com/736x/8a/35/33/8a35338bbf67c86a198ba2dd926edd82.jpg"),
NSURL(string: "https://s-media-cache-ak0.pinimg.com/736x/4d/6e/3c/4d6e3cf970031116c57486e85c2a4cab.jpg"),
NSURL(string: "https://s-media-cache-ak0.pinimg.com/736x/54/25/ee/5425eeccba78731cf7be70f0b8808bd2.jpg"),
NSURL(string: "https://s-media-cache-ak0.pinimg.com/736x/04/f1/3f/04f13fdb7580dcbe8c4d6b7d5a0a5ec2.jpg"),
NSURL(string: "https://s-media-cache-ak0.pinimg.com/736x/dc/16/4e/dc164ed33af9d899e5ed188e642f00e9.jpg"),
NSURL(string: "https://s-media-cache-ak0.pinimg.com/736x/c1/06/13/c106132936189b6cb654671f2a2183ed.jpg"),
NSURL(string: "https://s-media-cache-ak0.pinimg.com/736x/46/43/ed/4643eda4e1be4273721a76a370b90346.jpg")
]
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: UICollectionViewDataSource
override func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
return 1
}
override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return kittenURLs.count
}
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! CollectionViewCell
cell.imageView.pin_setImageFromURL(kittenURLs[indexPath.row])
return cell
}
}

View File

@@ -0,0 +1,35 @@
//
// DegradedViewController.swift
// PINRemoteImage.tvOSExample
//
// Created by Isaac Overacker on 2/6/16.
//
//
import UIKit
import PINRemoteImage
class DegradedViewController: UIViewController {
@IBOutlet weak var imageView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
PINRemoteImageManager.sharedImageManager().setShouldUpgradeLowQualityImages(true, completion: nil)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
imageView.pin_setImageFromURLs([
NSURL(string: "https://placekitten.com/101/101")!,
NSURL(string: "https://placekitten.com/401/401")!,
NSURL(string: "https://placekitten.com/801/801")!
])
}
}

View File

@@ -0,0 +1,34 @@
//
// GIFViewController.swift
// PINRemoteImage.tvOSExample
//
// Created by Isaac Overacker on 2/6/16.
//
//
import UIKit
import PINRemoteImage
class GIFViewController: UIViewController {
@IBOutlet weak var animatedImageView: FLAnimatedImageView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
if let url = NSURL(string: "https://i.giphy.com/l49FiX2pvMPPmCfSw.gif") {
animatedImageView.pin_setImageFromURL(url)
}
}
}

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key></key>
<string></string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>arm64</string>
</array>
</dict>
</plist>

View File

@@ -0,0 +1,77 @@
//
// ProcessingViewController.swift
// PINRemoteImage.tvOSExample
//
// Created by Isaac Overacker on 2/6/16.
//
//
import UIKit
import PINRemoteImage
class ProcessingViewController: UIViewController {
@IBOutlet weak var imageView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
if let url = NSURL(string: "https://s-media-cache-ak0.pinimg.com/1200x/2e/0c/c5/2e0cc5d86e7b7cd42af225c29f21c37f.jpg") {
imageView.pin_setImageFromURL(url,
processorKey: "rounded",
processor: { (result, cost) -> UIImage? in
if let image = result.image {
let radius = CGFloat(7.0)
let targetSize = CGSize(width: 200, height: 300)
let imageRect = CGRect(x: 0, y: 0, width: targetSize.width, height: targetSize.height)
UIGraphicsBeginImageContext(imageRect.size)
let bezierPath = UIBezierPath(roundedRect: imageRect, cornerRadius: radius)
bezierPath.addClip()
let widthMultiplier = CGFloat(targetSize.width / image.size.width)
let heightMultiplier = CGFloat(targetSize.height / image.size.height)
let sizeMultiplier = max(widthMultiplier, heightMultiplier)
var drawRect = CGRect(x: 0, y: 0, width: image.size.width * sizeMultiplier, height: image.size.height * sizeMultiplier)
if CGRectGetMaxX(drawRect) > CGRectGetMaxX(imageRect) {
drawRect.origin.x -= (CGRectGetMaxX(drawRect) - CGRectGetMaxX(imageRect)) / 2.0;
}
if CGRectGetMaxY(drawRect) > CGRectGetMaxY(imageRect) {
drawRect.origin.y -= (CGRectGetMaxY(drawRect) - CGRectGetMaxY(imageRect)) / 2.0;
}
image.drawInRect(drawRect)
UIColor.redColor().setStroke()
bezierPath.lineWidth = 5.0
bezierPath.stroke()
let ctx = UIGraphicsGetCurrentContext();
CGContextSetBlendMode(ctx, .Overlay);
CGContextSetAlpha(ctx, 0.5);
if let logo = UIImage(named: "white-pinterest-logo") {
CGContextScaleCTM(ctx, 1.0, -1.0);
CGContextTranslateCTM(ctx, 0.0, -drawRect.size.height);
CGContextDrawImage(ctx, CGRect(x: 0, y: 0, width: logo.size.width, height: logo.size.height), logo.CGImage);
}
let processedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return processedImage;
}
return nil
})
}
}
}

View File

@@ -0,0 +1,50 @@
//
// ProgressiveViewController.swift
// PINRemoteImage.tvOSExample
//
// Created by Isaac Overacker on 2/6/16.
//
//
import UIKit
import PINRemoteImage
class ProgressiveViewController: UIViewController {
@IBOutlet weak var imageView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
imageView.pin_updateWithProgress = true
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
if let url = NSURL(string: "https://s-media-cache-ak0.pinimg.com/1200x/2e/0c/c5/2e0cc5d86e7b7cd42af225c29f21c37f.jpg") {
PINRemoteImageManager.sharedImageManager().setProgressThresholds([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9], completion: nil)
imageView.pin_setImageFromURL(url)
var progress = [UIImage]()
PINRemoteImageManager.sharedImageManager().downloadImageWithURL(url,
options: .DownloadOptionsNone,
progress: { result in
if let image = result.image {
progress.append(image)
}
}, completion: { result in
if let image = result.image {
progress.append(image)
}
})
}
}
}

View File

@@ -0,0 +1,35 @@
//
// WebPViewController.swift
// PINRemoteImage.tvOSExample
//
// Created by Isaac Overacker on 2/6/16.
//
//
import UIKit
import PINRemoteImage
class WebPViewController: UIViewController {
@IBOutlet weak var imageView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
if let url = NSURL(string: "https://github.com/samdutton/simpl/blob/master/picturetype/kittens.webp") {
imageView.pin_setImageFromURL(url)
}
}
}