Repository: AfrozZaheer/AZSafariCollectionViewLayout
Branch: master
Commit: 837137629d29
Files: 18
Total size: 51.2 KB
Directory structure:
gitextract_y2zrgpbq/
├── .gitignore
├── .swift-version
├── AZSafariCollectionViewLayout.podspec
├── Example/
│ ├── AZTestLayout/
│ │ ├── AZExploreLayout.swift
│ │ ├── AZSafariLayout.swift
│ │ ├── AppDelegate.swift
│ │ ├── Assets.xcassets/
│ │ │ └── AppIcon.appiconset/
│ │ │ └── Contents.json
│ │ ├── Base.lproj/
│ │ │ ├── LaunchScreen.storyboard
│ │ │ └── Main.storyboard
│ │ ├── Info.plist
│ │ ├── TabCollectionViewCell.swift
│ │ ├── TabCollectionViewCell.xib
│ │ └── ViewController.swift
│ └── AZTestLayout.xcodeproj/
│ ├── project.pbxproj
│ └── project.xcworkspace/
│ └── contents.xcworkspacedata
├── LICENSE
├── README.md
└── Source/
└── AZSafariCollectionViewLayout.swift
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
# Add any directories, files, or patterns you don't want to be tracked by version control
# Created by http://www.gitignore.io
### OSX ###
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear on external disk
.Spotlight-V100
.Trashes
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Swift ###
# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
#
# Pods/
### Xcode ###
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.xcuserstate
# Created by https://www.gitignore.io/api/macos
### macOS ###
*.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# End of https://www.gitignore.io/api/macos
================================================
FILE: .swift-version
================================================
4.0
================================================
FILE: AZSafariCollectionViewLayout.podspec
================================================
Pod::Spec.new do |s|
s.name = "AZSafariCollectionViewLayout"
s.version = "0.1.0"
s.summary = "AZSafariCollectionViewLayout is replica of safari browser history page layout"
s.description = <<-DESC
AZSafariCollectionViewLayout is replica of safari browser history page layout. very easy to use, IBInspectable are given for easy integration.
DESC
s.homepage = "https://github.com/AfrozZaheer/AZSafariCollectionViewLayout"
s.platform = :ios, "9.3"
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { "AfrozZaheer" => "afrozezaheer@gmail.com" }
s.source = { :git => "https://github.com/AfrozZaheer/AZSafariCollectionViewLayout.git" }
s.source_files = 'Source/**/*.{swift}'
end
================================================
FILE: Example/AZTestLayout/AZExploreLayout.swift
================================================
//
// AZExploreLayout.swift
// AZTestLayout
//
// Created by Afroz Zaheer on 22/02/2018.
// Copyright © 2018 Afroz Zaheer. All rights reserved.
//
import Foundation
import UIKit
class AZExploreCollectionViewLayout: UICollectionViewLayout {
var attributes = Array<UICollectionViewLayoutAttributes>()
var contentSize: CGSize = CGSize(width: 0, height: 0)
var itemGap: CGFloat?
override func prepare() {
super.prepare()
if collectionView?.numberOfSections != 1 {
return
}
itemGap = CGFloat(roundf(Float(self.collectionView!.frame.size.height*0.2)))
var top = CGFloat(0.0)
let left = CGFloat(0.0)
let width = collectionView?.frame.size.width
let height = (collectionView?.frame.size.height)!
self.contentSize = CGSize(width: width!, height: height)
guard let limit = collectionView?.numberOfItems(inSection: 0) else {
return
}
for item in 0..<limit {
let indexPath = IndexPath(item: item, section: 0)
let attribute = UICollectionViewLayoutAttributes(forCellWith: indexPath)
let frame = CGRect(x: left, y: top, width: width!, height: height)
attribute.frame = frame
attribute.zIndex = item
let angleOfRotation = CGFloat(-00.0)
let rotation = CATransform3DMakeRotation((CGFloat.pi*angleOfRotation/180.0), 1.0, 0.0, 0.0)
let depth = CGFloat(30.0)
let translateDown = CATransform3DMakeTranslation(0.0, 0.0, -depth)
let translateUp = CATransform3DMakeTranslation(0.0, 0.0, depth)
var scale = CATransform3DIdentity
scale.m34 = -1.0/1500.0
let perspective = CATransform3DConcat(CATransform3DConcat(translateDown, scale), translateUp)
let transform = CATransform3DConcat(rotation, perspective)
attribute.transform3D = transform
self.attributes.append(attribute)
top += height
}
if self.attributes.count > 0 {
let lastItemAttributes = self.attributes.last
let newHeight = (lastItemAttributes?.frame.origin.y)! + (lastItemAttributes?.frame.size.height)!
let newWidth = width!
self.contentSize = CGSize(width: newWidth, height: newHeight)
}
}
override var collectionViewContentSize: CGSize {
return self.contentSize
}
override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
var visibleLayoutAttributes = [UICollectionViewLayoutAttributes]()
for attributes in self.attributes {
if attributes.frame.intersects(rect) {
visibleLayoutAttributes.append(attributes)
}
}
return visibleLayoutAttributes
}
override func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
return self.attributes[indexPath.item]
}
override func shouldInvalidateLayout(forBoundsChange newBounds: CGRect) -> Bool {
return true
}
override func initialLayoutAttributesForAppearingItem(at itemIndexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
return self.attributes[itemIndexPath.item]
}
}
================================================
FILE: Example/AZTestLayout/AZSafariLayout.swift
================================================
//
// AZSafariLayout.swift
// AZSafariLayout
//
// Created by Afroz Zaheer on 22/02/2018.
// Copyright © 2018 Afroz Zaheer. All rights reserved.
//
import UIKit
class AZSafariCollectionViewLayout: UICollectionViewLayout {
var attributes = Array<UICollectionViewLayoutAttributes>()
var contentSize: CGSize = CGSize(width: 0, height: 0)
@IBInspectable var itemGap: CGFloat = 50
@IBInspectable var height : CGFloat = 0
@IBInspectable var angleOfRotation : CGFloat = -30
override func prepare() {
super.prepare()
if collectionView?.numberOfSections != 1 {
return
}
//itemGap = CGFloat(roundf(Float(self.collectionView!.frame.size.height*0.1)))
var top = CGFloat(0.0)
let left = CGFloat(0.0)
let width = collectionView?.frame.size.width
self.contentSize = CGSize(width: width!, height: height)
guard let limit = collectionView?.numberOfItems(inSection: 0) else {
return
}
for item in 0..<limit {
let indexPath = IndexPath(item: item, section: 0)
let attribute = UICollectionViewLayoutAttributes(forCellWith: indexPath)
let frame = CGRect(x: left, y: top, width: width!, height: height)
attribute.frame = frame
attribute.zIndex = item
angleOfRotation = CGFloat(-30.0)
var frameOffset = Float((self.collectionView?.contentOffset.y)! - frame.origin.y) - floorf(Float(self.collectionView!.frame.size.height/10.0))
if frameOffset > 0 {
frameOffset = frameOffset/5.0
frameOffset = min(frameOffset, 30.0)
angleOfRotation += CGFloat(frameOffset)
}
let rotation = CATransform3DMakeRotation((CGFloat.pi*angleOfRotation/180.0), 1.0, 0.0, 0.0)
let depth = CGFloat(250.0)
let translateDown = CATransform3DMakeTranslation(0.0, 0.0, -depth)
let translateUp = CATransform3DMakeTranslation(0.0, 0.0, depth)
var scale = CATransform3DIdentity
scale.m34 = -1.0/1500.0
let perspective = CATransform3DConcat(CATransform3DConcat(translateDown, scale), translateUp)
let transform = CATransform3DConcat(rotation, perspective)
let gap = self.itemGap
attribute.transform3D = transform
self.attributes.append(attribute)
top += gap
}
if self.attributes.count > 0 {
let lastItemAttributes = self.attributes.last
let newHeight = (lastItemAttributes?.frame.origin.y)! + (lastItemAttributes?.frame.size.height)! + 20
let newWidth = (self.collectionView?.frame.size.width)!
self.contentSize = CGSize(width: newWidth, height: newHeight)
}
}
override var collectionViewContentSize: CGSize {
return self.contentSize
}
override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
var visibleLayoutAttributes = [UICollectionViewLayoutAttributes]()
for attributes in self.attributes {
if attributes.frame.intersects(rect) {
visibleLayoutAttributes.append(attributes)
}
}
return visibleLayoutAttributes
}
override func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
return self.attributes[indexPath.item]
}
override func shouldInvalidateLayout(forBoundsChange newBounds: CGRect) -> Bool {
return true
}
override func initialLayoutAttributesForAppearingItem(at itemIndexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
return self.attributes[itemIndexPath.item]
}
}
================================================
FILE: Example/AZTestLayout/AppDelegate.swift
================================================
//
// AppDelegate.swift
// AZTestLayout
//
// Created by Afroz Zaheer on 22/02/2018.
// Copyright © 2018 Afroz Zaheer. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> 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 invalidate graphics rendering callbacks. 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 active 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:.
}
}
================================================
FILE: Example/AZTestLayout/Assets.xcassets/AppIcon.appiconset/Contents.json
================================================
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example/AZTestLayout/Base.lproj/LaunchScreen.storyboard
================================================
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" systemVersion="17A277" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
================================================
FILE: Example/AZTestLayout/Base.lproj/Main.storyboard
================================================
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="AZTestLayout" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" prefetchingEnabled="NO" translatesAutoresizingMaskIntoConstraints="NO" id="YER-8k-FBe">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<color key="backgroundColor" white="0.33333333333333331" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="MDM-L8-nWR">
<size key="itemSize" width="50" height="50"/>
<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/>
<connections>
<outlet property="dataSource" destination="BYZ-38-t0r" id="h90-tj-Pcv"/>
<outlet property="delegate" destination="BYZ-38-t0r" id="xMG-P9-TG5"/>
</connections>
</collectionView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="YER-8k-FBe" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" id="GHN-kc-hPe"/>
<constraint firstItem="YER-8k-FBe" firstAttribute="top" secondItem="8bC-Xf-vdC" secondAttribute="top" id="JMZ-IV-CQ2"/>
<constraint firstItem="6Tk-OE-BBY" firstAttribute="trailing" secondItem="YER-8k-FBe" secondAttribute="trailing" id="ZbL-nr-jAe"/>
<constraint firstAttribute="bottom" secondItem="YER-8k-FBe" secondAttribute="bottom" id="tgR-GQ-tBY"/>
</constraints>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
<connections>
<outlet property="collectionView" destination="YER-8k-FBe" id="5k6-Mg-SKH"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
</document>
================================================
FILE: Example/AZTestLayout/Info.plist
================================================
<?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>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</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>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
================================================
FILE: Example/AZTestLayout/TabCollectionViewCell.swift
================================================
//
// TabCollectionViewCell.swift
// AZTestLayout
//
// Created by Afroz Zaheer on 22/02/2018.
// Copyright © 2018 Afroz Zaheer. All rights reserved.
//
import UIKit
import WebKit
class TabCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var webView: UIWebView!
@IBOutlet weak var bgView: UIView!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
}
================================================
FILE: Example/AZTestLayout/TabCollectionViewCell.xib
================================================
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="TabCollectionViewCell" id="gTV-IL-0wX" customClass="TabCollectionViewCell" customModule="AZTestLayout" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="372" height="360"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="372" height="360"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view clipsSubviews="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="SsC-2H-ahl">
<rect key="frame" x="0.0" y="0.0" width="372" height="360"/>
<subviews>
<webView userInteractionEnabled="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="4ib-Kp-C9i">
<rect key="frame" x="0.0" y="0.0" width="372" height="360"/>
<color key="backgroundColor" red="0.36078431370000003" green="0.38823529410000002" blue="0.4039215686" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</webView>
</subviews>
<color key="backgroundColor" white="0.33333333333333331" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="4ib-Kp-C9i" secondAttribute="trailing" id="97V-Lb-pAe"/>
<constraint firstAttribute="bottom" secondItem="4ib-Kp-C9i" secondAttribute="bottom" id="LS2-MY-xqi"/>
<constraint firstItem="4ib-Kp-C9i" firstAttribute="top" secondItem="SsC-2H-ahl" secondAttribute="top" id="ZrR-uc-0hd"/>
<constraint firstItem="4ib-Kp-C9i" firstAttribute="leading" secondItem="SsC-2H-ahl" secondAttribute="leading" id="dK4-sy-kPC"/>
</constraints>
</view>
</subviews>
</view>
<constraints>
<constraint firstAttribute="trailing" secondItem="SsC-2H-ahl" secondAttribute="trailing" id="6TT-jm-QEO"/>
<constraint firstItem="SsC-2H-ahl" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" id="8GF-UM-NqO"/>
<constraint firstItem="SsC-2H-ahl" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" id="gIb-Bx-7QM"/>
<constraint firstAttribute="bottom" secondItem="SsC-2H-ahl" secondAttribute="bottom" id="kqW-Yg-cbi"/>
</constraints>
<viewLayoutGuide key="safeArea" id="ZTg-uK-7eu"/>
<size key="customSize" width="372" height="360"/>
<connections>
<outlet property="bgView" destination="SsC-2H-ahl" id="Cli-CW-RbF"/>
<outlet property="webView" destination="4ib-Kp-C9i" id="kqU-Oz-ksf"/>
</connections>
<point key="canvasLocation" x="-6" y="17"/>
</collectionViewCell>
</objects>
</document>
================================================
FILE: Example/AZTestLayout/ViewController.swift
================================================
//
// ViewController.swift
// AZTestLayout
//
// Created by Afroz Zaheer on 22/02/2018.
// Copyright © 2018 Afroz Zaheer. All rights reserved.
//
import UIKit
import WebKit
class ViewController: UIViewController {
@IBOutlet weak var collectionView: UICollectionView!
let exploreLayout = AZExploreCollectionViewLayout()
let browsingLayout = AZSafariCollectionViewLayout()
let sitesData = ["https://www.google.com","https://www.apple.com","https://www.yahoo.com","https://www.bing.com","https://www.msn.com","https://www.cocoacontrols.com","https://www.github.com/AfrozZaheer","https://www.google.com" ]
var isSelected = false
override func viewDidLoad() {
super.viewDidLoad()
collectionView.register(UINib(nibName: "TabCollectionViewCell", bundle: nil), forCellWithReuseIdentifier: "TabCollectionViewCell")
collectionView.setCollectionViewLayout(browsingLayout, animated: true)
browsingLayout.height = (collectionView?.frame.size.height)!
browsingLayout.itemGap = 150
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
// collectionView.scrollToItem(at: IndexPath(item: sitesData.count - 1, section: 0), at: .bottom, animated: true)
}
}
extension ViewController: UICollectionViewDelegate, UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return sitesData.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "TabCollectionViewCell", for: indexPath) as! TabCollectionViewCell
DispatchQueue.once(token: "\(indexPath.item)") {
DispatchQueue.main.async {
let site = self.sitesData[indexPath.item]
let request = URLRequest(url: URL(string: site)!)
cell.webView.loadRequest(request)
}
}
cell.bgView.layer.shadowColor = UIColor.black.cgColor
cell.bgView.layer.shadowOffset = CGSize(width: 0.0, height: -20.0)
cell.bgView.layer.shadowOpacity = 0.6
cell.bgView.layer.shadowRadius = 20.0
cell.bgView.layer.shadowPath = UIBezierPath(rect: cell.contentView.bounds).cgPath
//cell.bgView.layer.shouldRasterize = true
cell.bgView.layer.cornerRadius = 15
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
DispatchQueue.main.async {
if self.isSelected == false {
collectionView.setCollectionViewLayout(self.exploreLayout, animated: true)
self.isSelected = true
}
else {
collectionView.setCollectionViewLayout(self.browsingLayout, animated: true)
self.isSelected = false
}
}
}
}
public extension DispatchQueue {
private static var _onceTracker = [String]()
/**
Executes a block of code, associated with a unique token, only once. The code is thread safe and will
only execute the code once even in the presence of multithreaded calls.
- parameter token: A unique reverse DNS style name such as com.vectorform.<name> or a GUID
- parameter block: Block to execute once
*/
public class func once(token: String, block:()->Void) {
objc_sync_enter(self); defer { objc_sync_exit(self) }
if _onceTracker.contains(token) {
return
}
_onceTracker.append(token)
block()
}
}
================================================
FILE: Example/AZTestLayout.xcodeproj/project.pbxproj
================================================
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 48;
objects = {
/* Begin PBXBuildFile section */
B8545A9A2046B92D004F04B7 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = B8545A992046B92D004F04B7 /* README.md */; };
B8764899203E9BBD00B1FA40 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8764898203E9BBD00B1FA40 /* AppDelegate.swift */; };
B876489B203E9BBD00B1FA40 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B876489A203E9BBD00B1FA40 /* ViewController.swift */; };
B876489E203E9BBD00B1FA40 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B876489C203E9BBD00B1FA40 /* Main.storyboard */; };
B87648A0203E9BBD00B1FA40 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B876489F203E9BBD00B1FA40 /* Assets.xcassets */; };
B87648A3203E9BBD00B1FA40 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B87648A1203E9BBD00B1FA40 /* LaunchScreen.storyboard */; };
B87648AB203E9BE900B1FA40 /* AZSafariLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = B87648AA203E9BE900B1FA40 /* AZSafariLayout.swift */; };
B87648AE203EA27100B1FA40 /* TabCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = B87648AC203EA27100B1FA40 /* TabCollectionViewCell.swift */; };
B87648AF203EA27100B1FA40 /* TabCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = B87648AD203EA27100B1FA40 /* TabCollectionViewCell.xib */; };
B895EBE920401D4600625F57 /* AZExploreLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = B895EBE820401D4600625F57 /* AZExploreLayout.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
B8545A992046B92D004F04B7 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../../README.md; sourceTree = "<group>"; };
B8764895203E9BBD00B1FA40 /* AZTestLayout.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AZTestLayout.app; sourceTree = BUILT_PRODUCTS_DIR; };
B8764898203E9BBD00B1FA40 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
B876489A203E9BBD00B1FA40 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
B876489D203E9BBD00B1FA40 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
B876489F203E9BBD00B1FA40 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
B87648A2203E9BBD00B1FA40 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
B87648A4203E9BBD00B1FA40 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
B87648AA203E9BE900B1FA40 /* AZSafariLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AZSafariLayout.swift; sourceTree = "<group>"; };
B87648AC203EA27100B1FA40 /* TabCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabCollectionViewCell.swift; sourceTree = "<group>"; };
B87648AD203EA27100B1FA40 /* TabCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = TabCollectionViewCell.xib; sourceTree = "<group>"; };
B895EBE820401D4600625F57 /* AZExploreLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AZExploreLayout.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
B8764892203E9BBD00B1FA40 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
B876488C203E9BBD00B1FA40 = {
isa = PBXGroup;
children = (
B8764897203E9BBD00B1FA40 /* AZTestLayout */,
B8764896203E9BBD00B1FA40 /* Products */,
);
sourceTree = "<group>";
};
B8764896203E9BBD00B1FA40 /* Products */ = {
isa = PBXGroup;
children = (
B8764895203E9BBD00B1FA40 /* AZTestLayout.app */,
);
name = Products;
sourceTree = "<group>";
};
B8764897203E9BBD00B1FA40 /* AZTestLayout */ = {
isa = PBXGroup;
children = (
B8545A992046B92D004F04B7 /* README.md */,
B8764898203E9BBD00B1FA40 /* AppDelegate.swift */,
B876489A203E9BBD00B1FA40 /* ViewController.swift */,
B876489C203E9BBD00B1FA40 /* Main.storyboard */,
B876489F203E9BBD00B1FA40 /* Assets.xcassets */,
B87648A1203E9BBD00B1FA40 /* LaunchScreen.storyboard */,
B87648A4203E9BBD00B1FA40 /* Info.plist */,
B87648AC203EA27100B1FA40 /* TabCollectionViewCell.swift */,
B87648AD203EA27100B1FA40 /* TabCollectionViewCell.xib */,
B87648AA203E9BE900B1FA40 /* AZSafariLayout.swift */,
B895EBE820401D4600625F57 /* AZExploreLayout.swift */,
);
path = AZTestLayout;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
B8764894203E9BBD00B1FA40 /* AZTestLayout */ = {
isa = PBXNativeTarget;
buildConfigurationList = B87648A7203E9BBD00B1FA40 /* Build configuration list for PBXNativeTarget "AZTestLayout" */;
buildPhases = (
B8764891203E9BBD00B1FA40 /* Sources */,
B8764892203E9BBD00B1FA40 /* Frameworks */,
B8764893203E9BBD00B1FA40 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = AZTestLayout;
productName = AZTestLayout;
productReference = B8764895203E9BBD00B1FA40 /* AZTestLayout.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
B876488D203E9BBD00B1FA40 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0920;
LastUpgradeCheck = 0920;
ORGANIZATIONNAME = "Afroz Zaheer";
TargetAttributes = {
B8764894203E9BBD00B1FA40 = {
CreatedOnToolsVersion = 9.2;
ProvisioningStyle = Automatic;
};
};
};
buildConfigurationList = B8764890203E9BBD00B1FA40 /* Build configuration list for PBXProject "AZTestLayout" */;
compatibilityVersion = "Xcode 8.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = B876488C203E9BBD00B1FA40;
productRefGroup = B8764896203E9BBD00B1FA40 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
B8764894203E9BBD00B1FA40 /* AZTestLayout */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
B8764893203E9BBD00B1FA40 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
B87648AF203EA27100B1FA40 /* TabCollectionViewCell.xib in Resources */,
B87648A3203E9BBD00B1FA40 /* LaunchScreen.storyboard in Resources */,
B8545A9A2046B92D004F04B7 /* README.md in Resources */,
B87648A0203E9BBD00B1FA40 /* Assets.xcassets in Resources */,
B876489E203E9BBD00B1FA40 /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
B8764891203E9BBD00B1FA40 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
B87648AE203EA27100B1FA40 /* TabCollectionViewCell.swift in Sources */,
B87648AB203E9BE900B1FA40 /* AZSafariLayout.swift in Sources */,
B876489B203E9BBD00B1FA40 /* ViewController.swift in Sources */,
B8764899203E9BBD00B1FA40 /* AppDelegate.swift in Sources */,
B895EBE920401D4600625F57 /* AZExploreLayout.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
B876489C203E9BBD00B1FA40 /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
B876489D203E9BBD00B1FA40 /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
B87648A1203E9BBD00B1FA40 /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
B87648A2203E9BBD00B1FA40 /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
B87648A5203E9BBD00B1FA40 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.2;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
B87648A6203E9BBD00B1FA40 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.2;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
B87648A8203E9BBD00B1FA40 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = CASVKBQG32;
INFOPLIST_FILE = AZTestLayout/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.AfrozZaheer.AZTestLayout;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
B87648A9203E9BBD00B1FA40 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = CASVKBQG32;
INFOPLIST_FILE = AZTestLayout/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.AfrozZaheer.AZTestLayout;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
B8764890203E9BBD00B1FA40 /* Build configuration list for PBXProject "AZTestLayout" */ = {
isa = XCConfigurationList;
buildConfigurations = (
B87648A5203E9BBD00B1FA40 /* Debug */,
B87648A6203E9BBD00B1FA40 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
B87648A7203E9BBD00B1FA40 /* Build configuration list for PBXNativeTarget "AZTestLayout" */ = {
isa = XCConfigurationList;
buildConfigurations = (
B87648A8203E9BBD00B1FA40 /* Debug */,
B87648A9203E9BBD00B1FA40 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = B876488D203E9BBD00B1FA40 /* Project object */;
}
================================================
FILE: Example/AZTestLayout.xcodeproj/project.xcworkspace/contents.xcworkspacedata
================================================
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:AZTestLayout.xcodeproj">
</FileRef>
</Workspace>
================================================
FILE: LICENSE
================================================
Copyright (c) 2017 Afroz Zaheer <afrozezaheer@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
================================================
FILE: README.md
================================================
# AZSafariCollectionViewLayout
[](https://github.com/sindresorhus/awesome)
[](https://img.shields.io/badge/swift%20-4.0-orange.svg)
[](https://img.shields.io/badge/support-CocoaPods-red.svg?style=flat.svg)
[](https://cocoapods.org/pods/AZSafariCollectionViewLayout)
[](https://img.shields.io/badge/License-MIT-brightgreen.svg?style=flat.svg)
[](https://cocoapods.org/pods/AZSafariCollectionViewLayout)
<p align="center">
<a href="https://i.imgur.com/tgCdFnK.gif">
<img src="https://i.imgur.com/tgCdFnK.gif" height="480">
</a>
</p>
## Features
* iOS Safari history view layout
* IBDesignAble for properties
* Few minutes integration
## Installation
### CocoaPods
[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command:
```bash
$ gem install cocoapods
```
To integrate AZSafariCollectionViewLayout controller into your Xcode project using CocoaPods, specify it in your `Podfile`:
```ruby
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!
target '<Your Target Name>' do
pod 'AZSafariCollectionViewLayout'
end
```
Then, run the following command:
```bash
$ pod install
```
## Usage
#### Step 1
* Set collectionView layout and give some design properties value.
```swift
class ViewController: UIViewController {
@IBOutlet weak var collectionView: UICollectionView!
let exploreLayout = AZExploreCollectionViewLayout()
let browsingLayout = AZSafariCollectionViewLayout()
var isSelected = false
override func viewDidLoad() {
super.viewDidLoad()
collectionView.register(UINib(nibName: "TabCollectionViewCell", bundle: nil), forCellWithReuseIdentifier: "TabCollectionViewCell")
collectionView.setCollectionViewLayout(browsingLayout, animated: true)
browsingLayout.height = (collectionView?.frame.size.height)!
browsingLayout.itemGap = 100
}
}
```
#### OR
* You can set these properties in storyboard

#### Done
Thats it, you successfully integrate AZSafariCollectionViewLayout
## License
AZSafariCollectionViewLayout is available under the MIT license. See the LICENSE file for more info.
## Author
**Afroz Zaheer** - (https://github.com/AfrozZaheer)
================================================
FILE: Source/AZSafariCollectionViewLayout.swift
================================================
//
// AZSafariLayout.swift
// AZSafariLayout
//
// Created by Afroz Zaheer on 22/02/2018.
// Copyright © 2018 Afroz Zaheer. All rights reserved.
//
import UIKit
public class AZSafariCollectionViewLayout: UICollectionViewLayout {
var attributes = Array<UICollectionViewLayoutAttributes>()
var contentSize: CGSize = CGSize(width: 0, height: 0)
@IBInspectable public var itemGap: CGFloat = 50
@IBInspectable public var itemHeight : CGFloat = 0
@IBInspectable public var itemAngleOfRotation : CGFloat = -30
override public init() {
super.init()
}
required public init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override public func prepare() {
super.prepare()
if collectionView?.numberOfSections != 1 {
return
}
//itemGap = CGFloat(roundf(Float(self.collectionView!.frame.size.height*0.1)))
var top = CGFloat(0.0)
let left = CGFloat(0.0)
let width = collectionView?.frame.size.width
self.contentSize = CGSize(width: width!, height: itemHeight)
guard let limit = collectionView?.numberOfItems(inSection: 0) else {
return
}
for item in 0..<limit {
let indexPath = IndexPath(item: item, section: 0)
let attribute = UICollectionViewLayoutAttributes(forCellWith: indexPath)
let frame = CGRect(x: left, y: top, width: width!, height: itemHeight)
attribute.frame = frame
attribute.zIndex = item
var angleOfRotation = itemAngleOfRotation
var frameOffset = Float((self.collectionView?.contentOffset.y)! - frame.origin.y) - floorf(Float(self.collectionView!.frame.size.height/10.0))
if frameOffset > 0 {
frameOffset = frameOffset/5.0
frameOffset = min(frameOffset, 30.0)
angleOfRotation += CGFloat(frameOffset)
}
let rotation = CATransform3DMakeRotation((CGFloat.pi*angleOfRotation/180.0), 1.0, 0.0, 0.0)
let depth = CGFloat(250.0)
let translateDown = CATransform3DMakeTranslation(0.0, 0.0, -depth)
let translateUp = CATransform3DMakeTranslation(0.0, 0.0, depth)
var scale = CATransform3DIdentity
scale.m34 = -1.0/1500.0
let perspective = CATransform3DConcat(CATransform3DConcat(translateDown, scale), translateUp)
let transform = CATransform3DConcat(rotation, perspective)
let gap = self.itemGap
attribute.transform3D = transform
self.attributes.append(attribute)
top += gap
}
if self.attributes.count > 0 {
let lastItemAttributes = self.attributes.last
let newHeight = (lastItemAttributes?.frame.origin.y)! + (lastItemAttributes?.frame.size.height)! + 20
let newWidth = (self.collectionView?.frame.size.width)!
self.contentSize = CGSize(width: newWidth, height: newHeight)
}
}
override public var collectionViewContentSize: CGSize {
return self.contentSize
}
override public func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
var visibleLayoutAttributes = [UICollectionViewLayoutAttributes]()
for attributes in self.attributes {
if attributes.frame.intersects(rect) {
visibleLayoutAttributes.append(attributes)
}
}
return visibleLayoutAttributes
}
override public func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
return self.attributes[indexPath.item]
}
override public func shouldInvalidateLayout(forBoundsChange newBounds: CGRect) -> Bool {
return true
}
override public func initialLayoutAttributesForAppearingItem(at itemIndexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
return self.attributes[itemIndexPath.item]
}
}
gitextract_y2zrgpbq/
├── .gitignore
├── .swift-version
├── AZSafariCollectionViewLayout.podspec
├── Example/
│ ├── AZTestLayout/
│ │ ├── AZExploreLayout.swift
│ │ ├── AZSafariLayout.swift
│ │ ├── AppDelegate.swift
│ │ ├── Assets.xcassets/
│ │ │ └── AppIcon.appiconset/
│ │ │ └── Contents.json
│ │ ├── Base.lproj/
│ │ │ ├── LaunchScreen.storyboard
│ │ │ └── Main.storyboard
│ │ ├── Info.plist
│ │ ├── TabCollectionViewCell.swift
│ │ ├── TabCollectionViewCell.xib
│ │ └── ViewController.swift
│ └── AZTestLayout.xcodeproj/
│ ├── project.pbxproj
│ └── project.xcworkspace/
│ └── contents.xcworkspacedata
├── LICENSE
├── README.md
└── Source/
└── AZSafariCollectionViewLayout.swift
Condensed preview — 18 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (57K chars).
[
{
"path": ".gitignore",
"chars": 1643,
"preview": "# Add any directories, files, or patterns you don't want to be tracked by version control\n# Created by http://www.gitign"
},
{
"path": ".swift-version",
"chars": 4,
"preview": "4.0\n"
},
{
"path": "AZSafariCollectionViewLayout.podspec",
"chars": 769,
"preview": "\nPod::Spec.new do |s|\n\n\n s.name = \"AZSafariCollectionViewLayout\"\n s.version = \"0.1.0\"\n s.summary = "
},
{
"path": "Example/AZTestLayout/AZExploreLayout.swift",
"chars": 3501,
"preview": "//\n// AZExploreLayout.swift\n// AZTestLayout\n//\n// Created by Afroz Zaheer on 22/02/2018.\n// Copyright © 2018 Afroz Z"
},
{
"path": "Example/AZTestLayout/AZSafariLayout.swift",
"chars": 4008,
"preview": "//\n// AZSafariLayout.swift\n// AZSafariLayout\n//\n// Created by Afroz Zaheer on 22/02/2018.\n// Copyright © 2018 Afroz "
},
{
"path": "Example/AZTestLayout/AppDelegate.swift",
"chars": 2179,
"preview": "//\n// AppDelegate.swift\n// AZTestLayout\n//\n// Created by Afroz Zaheer on 22/02/2018.\n// Copyright © 2018 Afroz Zahee"
},
{
"path": "Example/AZTestLayout/Assets.xcassets/AppIcon.appiconset/Contents.json",
"chars": 1495,
"preview": "{\n \"images\" : [\n {\n \"idiom\" : \"iphone\",\n \"size\" : \"20x20\",\n \"scale\" : \"2x\"\n },\n {\n \"idiom\""
},
{
"path": "Example/AZTestLayout/Base.lproj/LaunchScreen.storyboard",
"chars": 1681,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<document type=\"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard"
},
{
"path": "Example/AZTestLayout/Base.lproj/Main.storyboard",
"chars": 4152,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<document type=\"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB\" version=\"3"
},
{
"path": "Example/AZTestLayout/Info.plist",
"chars": 1463,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/P"
},
{
"path": "Example/AZTestLayout/TabCollectionViewCell.swift",
"chars": 425,
"preview": "//\n// TabCollectionViewCell.swift\n// AZTestLayout\n//\n// Created by Afroz Zaheer on 22/02/2018.\n// Copyright © 2018 A"
},
{
"path": "Example/AZTestLayout/TabCollectionViewCell.xib",
"chars": 4317,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<document type=\"com.apple.InterfaceBuilder3.CocoaTouch.XIB\" version=\"3.0\" toolsVe"
},
{
"path": "Example/AZTestLayout/ViewController.swift",
"chars": 3880,
"preview": "//\n// ViewController.swift\n// AZTestLayout\n//\n// Created by Afroz Zaheer on 22/02/2018.\n// Copyright © 2018 Afroz Za"
},
{
"path": "Example/AZTestLayout.xcodeproj/project.pbxproj",
"chars": 14507,
"preview": "// !$*UTF8*$!\n{\n\tarchiveVersion = 1;\n\tclasses = {\n\t};\n\tobjectVersion = 48;\n\tobjects = {\n\n/* Begin PBXBuildFile section *"
},
{
"path": "Example/AZTestLayout.xcodeproj/project.xcworkspace/contents.xcworkspacedata",
"chars": 157,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Workspace\n version = \"1.0\">\n <FileRef\n location = \"self:AZTestLayout.xc"
},
{
"path": "LICENSE",
"chars": 1081,
"preview": "Copyright (c) 2017 Afroz Zaheer <afrozezaheer@gmail.com>\n\nPermission is hereby granted, free of charge, to any person ob"
},
{
"path": "README.md",
"chars": 2872,
"preview": "# AZSafariCollectionViewLayout\n\n[. The extraction includes 18 files (51.2 KB), approximately 14.6k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.