├── .swift-version ├── Screenshot └── CycleBanner_Main.gif ├── CycleBanner.xcworkspace ├── xcuserdata │ └── jiar.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── UserInterfaceState.xcuserstate └── contents.xcworkspacedata ├── CycleBanner.xcodeproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── jiar.xcuserdatad │ │ └── UserInterfaceState.xcuserstate ├── xcuserdata │ └── jiar.xcuserdatad │ │ └── xcschemes │ │ ├── xcschememanagement.plist │ │ ├── CycleBannerTests.xcscheme │ │ └── CycleBanner.xcscheme └── project.pbxproj ├── Example ├── Example.xcodeproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── jiar.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ ├── xcuserdata │ │ └── jiar.xcuserdatad │ │ │ └── xcschemes │ │ │ ├── xcschememanagement.plist │ │ │ └── Example.xcscheme │ └── project.pbxproj ├── Example │ ├── CustomCycleBannerViewCell.swift │ ├── Info.plist │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── AppDelegate.swift │ ├── ViewController.swift │ └── CustomCycleBannerViewCell.xib ├── ExampleTests │ ├── Info.plist │ └── ExampleTests.swift └── ExampleUITests │ ├── Info.plist │ └── ExampleUITests.swift ├── CycleBanner.podspec ├── CycleBanner ├── CycleBanner.h ├── Info.plist └── CycleBanner.swift ├── CycleBannerTests ├── Info.plist └── CycleBannerTests.swift ├── README.md └── LICENSE /.swift-version: -------------------------------------------------------------------------------- 1 | 4.0 2 | -------------------------------------------------------------------------------- /Screenshot/CycleBanner_Main.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jiar/CycleBanner/HEAD/Screenshot/CycleBanner_Main.gif -------------------------------------------------------------------------------- /CycleBanner.xcworkspace/xcuserdata/jiar.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /CycleBanner.xcworkspace/xcuserdata/jiar.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jiar/CycleBanner/HEAD/CycleBanner.xcworkspace/xcuserdata/jiar.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /CycleBanner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CycleBanner.xcodeproj/project.xcworkspace/xcuserdata/jiar.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jiar/CycleBanner/HEAD/CycleBanner.xcodeproj/project.xcworkspace/xcuserdata/jiar.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Example/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/Example.xcodeproj/project.xcworkspace/xcuserdata/jiar.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jiar/CycleBanner/HEAD/Example/Example.xcodeproj/project.xcworkspace/xcuserdata/jiar.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /CycleBanner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /CycleBanner.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'CycleBanner' 3 | s.version = '1.0' 4 | s.summary = 'Infinite horizontal scrolling control.' 5 | s.homepage = 'https://github.com/Jiar/CycleBanner' 6 | s.license = { :type => "Apache-2.0", :file => "LICENSE" } 7 | s.author = { "Jiar" => "jiar.world@gmail.com" } 8 | s.ios.deployment_target = '9.0' 9 | s.source = { :git => "https://github.com/Jiar/CycleBanner.git", :tag => "#{s.version}" } 10 | s.source_files = 'CycleBanner/*.swift' 11 | s.module_name = 'CycleBanner' 12 | end 13 | -------------------------------------------------------------------------------- /CycleBanner/CycleBanner.h: -------------------------------------------------------------------------------- 1 | // 2 | // CycleBanner.h 3 | // CycleBanner 4 | // 5 | // Created by Jiar on 2017/12/18. 6 | // Copyright © 2017年 Jiar. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for CycleBanner. 12 | FOUNDATION_EXPORT double CycleBannerVersionNumber; 13 | 14 | //! Project version string for CycleBanner. 15 | FOUNDATION_EXPORT const unsigned char CycleBannerVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /Example/Example/CustomCycleBannerViewCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CustomCycleBannerViewCell.swift 3 | // Example 4 | // 5 | // Created by Jiar on 2017/12/18. 6 | // Copyright © 2017年 Jiar. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import CycleBanner 11 | 12 | class CustomCycleBannerViewCell: CycleBannerViewCell { 13 | 14 | @IBOutlet weak var titleLabel: UILabel! 15 | 16 | override func awakeFromNib() { 17 | super.awakeFromNib() 18 | layer.cornerRadius = 4 19 | layer.masksToBounds = true 20 | } 21 | 22 | func config(_ title: String) { 23 | titleLabel.text = title 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /CycleBannerTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Example/ExampleTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Example/ExampleUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Example/Example.xcodeproj/xcuserdata/jiar.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Example.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 80B218391FE7B3150049A3F8 16 | 17 | primary 18 | 19 | 20 | 80B2184D1FE7B3150049A3F8 21 | 22 | primary 23 | 24 | 25 | 80B218581FE7B3150049A3F8 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /CycleBanner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSPrincipalClass 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /CycleBanner.xcodeproj/xcuserdata/jiar.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | CycleBanner.xcscheme 8 | 9 | orderHint 10 | 1 11 | 12 | CycleBannerTests.xcscheme 13 | 14 | orderHint 15 | 2 16 | 17 | 18 | SuppressBuildableAutocreation 19 | 20 | 80B218021FE7B1840049A3F8 21 | 22 | primary 23 | 24 | 25 | 80B2180B1FE7B1850049A3F8 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Example/ExampleTests/ExampleTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ExampleTests.swift 3 | // ExampleTests 4 | // 5 | // Created by Jiar on 2017/12/18. 6 | // Copyright © 2017年 Jiar. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import Example 11 | 12 | class ExampleTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | // Use XCTAssert and related functions to verify your tests produce the correct results. 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /CycleBannerTests/CycleBannerTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CycleBannerTests.swift 3 | // CycleBannerTests 4 | // 5 | // Created by Jiar on 2017/12/18. 6 | // Copyright © 2017年 Jiar. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import CycleBanner 11 | 12 | class CycleBannerTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | // Use XCTAssert and related functions to verify your tests produce the correct results. 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /Example/ExampleUITests/ExampleUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ExampleUITests.swift 3 | // ExampleUITests 4 | // 5 | // Created by Jiar on 2017/12/18. 6 | // Copyright © 2017年 Jiar. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class ExampleUITests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | 18 | // In UI tests it is usually best to stop immediately when a failure occurs. 19 | continueAfterFailure = false 20 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 21 | XCUIApplication().launch() 22 | 23 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 24 | } 25 | 26 | override func tearDown() { 27 | // Put teardown code here. This method is called after the invocation of each test method in the class. 28 | super.tearDown() 29 | } 30 | 31 | func testExample() { 32 | // Use recording to get started writing UI tests. 33 | // Use XCTAssert and related functions to verify your tests produce the correct results. 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /Example/Example/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | CycleBanner 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /Example/Example/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /CycleBanner.xcodeproj/xcuserdata/jiar.xcuserdatad/xcschemes/CycleBannerTests.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 16 | 18 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 41 | 42 | 43 | 44 | 50 | 51 | 53 | 54 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /Example/Example/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Example 4 | // 5 | // Created by Jiar on 2017/12/18. 6 | // Copyright © 2017年 Jiar. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // 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. 24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // 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. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // 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. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // 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. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /Example/Example/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // Example 4 | // 5 | // Created by Jiar on 2017/12/18. 6 | // Copyright © 2017年 Jiar. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import CycleBanner 11 | 12 | class ViewController: UIViewController { 13 | 14 | @IBOutlet weak var cycleBannerView: CycleBannerView! 15 | fileprivate var cycleBannerCount = 8 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | cycleBannerView.register(UINib(nibName: "CustomCycleBannerViewCell", bundle: nil), forCellReuseIdentifier: "Cell") 20 | let space: CGFloat = 10 21 | let rowSpace: CGFloat = 10 22 | cycleBannerView.rowSpace = rowSpace 23 | cycleBannerView.rowWidth = view.bounds.width-2*(space+rowSpace) 24 | cycleBannerView.timeInterval = 3 25 | cycleBannerView.autoSlide = true 26 | cycleBannerView.isHiddenPageControl = false 27 | cycleBannerView.delegate = self 28 | cycleBannerView.dataSource = self 29 | cycleBannerView.reloadData() 30 | } 31 | 32 | @IBAction func randomCountAction(_ sender: Any) { 33 | cycleBannerCount = random(in: 0...10) 34 | cycleBannerView.reloadData() 35 | } 36 | 37 | @IBAction func randomWidthAndSpaceAction(_ sender: Any) { 38 | let space = CGFloat(random(in: 10...20)) 39 | let rowSpace = CGFloat(random(in: 10...20)) 40 | cycleBannerView.rowSpace = rowSpace 41 | cycleBannerView.rowWidth = view.bounds.width-2*(space+rowSpace) 42 | } 43 | 44 | func random(in range: CountableClosedRange) -> Int { 45 | let count = UInt32(range.upperBound - range.lowerBound) 46 | return Int(arc4random_uniform(count)) + range.lowerBound 47 | } 48 | 49 | } 50 | 51 | extension ViewController: CycleBannerViewDataSource { 52 | 53 | func numberOfBanners(in cycleBannerView: CycleBannerView) -> Int { 54 | return cycleBannerCount 55 | } 56 | 57 | func cycleBannerView(_ cycleBannerView: CycleBannerView, cellForRowAt index: Int) -> CycleBannerViewCell { 58 | let cell = cycleBannerView.dequeueReusableCell(withIdentifier: "Cell") as! CustomCycleBannerViewCell 59 | cell.config("\(index)") 60 | return cell 61 | } 62 | 63 | } 64 | 65 | extension ViewController: CycleBannerViewDelegate { 66 | 67 | func cycleBannerView(_ cycleBannerView: CycleBannerView, didSelectRowAt index: Int) { 68 | print("select at: \(index)") 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CycleBanner 2 | Infinite horizontal scrolling control. 3 | 4 |

5 | 6 | CycleBanner 7 | 8 |

9 | 10 | ## Requirements 11 | 12 | - iOS 9.0+ 13 | - Xcode 9.0+ 14 | - Swift 4.0+ 15 | 16 | ## CocoaPods 17 | 18 | [CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command: 19 | 20 | ```bash 21 | $ gem install cocoapods 22 | ``` 23 | 24 | > CocoaPods 1.1.0+ is required to build CycleBanner 1.0 25 | 26 | To integrate CycleBanner into your Xcode project using CocoaPods, specify it in your `Podfile`: 27 | 28 | ```ruby 29 | source 'https://github.com/CocoaPods/Specs.git' 30 | platform :ios, '9.0' 31 | use_frameworks! 32 | 33 | target '' do 34 | pod 'CycleBanner', '~> 1.0' 35 | end 36 | ``` 37 | 38 | Then, run the following command: 39 | 40 | ```bash 41 | $ pod install 42 | ``` 43 | 44 | ## Usage 45 | 46 | ```swift 47 | 48 | import UIKit 49 | import CycleBanner 50 | 51 | class ViewController: UIViewController { 52 | 53 | @IBOutlet weak var cycleBannerView: CycleBannerView! 54 | fileprivate var cycleBannerCount = 8 55 | 56 | override func viewDidLoad() { 57 | super.viewDidLoad() 58 | cycleBannerView.register(UINib(nibName: "CustomCycleBannerViewCell", bundle: nil), forCellReuseIdentifier: "Cell") 59 | let space: CGFloat = 10 60 | let rowSpace: CGFloat = 10 61 | cycleBannerView.rowSpace = rowSpace 62 | cycleBannerView.rowWidth = view.bounds.width-2*(space+rowSpace) 63 | cycleBannerView.timeInterval = 3 64 | cycleBannerView.autoSlide = true 65 | cycleBannerView.isHiddenPageControl = false 66 | cycleBannerView.delegate = self 67 | cycleBannerView.dataSource = self 68 | cycleBannerView.reloadData() 69 | } 70 | } 71 | 72 | extension ViewController: CycleBannerViewDataSource { 73 | 74 | func numberOfBanners(in cycleBannerView: CycleBannerView) -> Int { 75 | return cycleBannerCount 76 | } 77 | 78 | func cycleBannerView(_ cycleBannerView: CycleBannerView, cellForRowAt index: Int) -> CycleBannerViewCell { 79 | let cell = cycleBannerView.dequeueReusableCell(withIdentifier: "Cell") as! CustomCycleBannerViewCell 80 | cell.config("\(index)") 81 | return cell 82 | } 83 | 84 | } 85 | 86 | extension ViewController: CycleBannerViewDelegate { 87 | 88 | func cycleBannerView(_ cycleBannerView: CycleBannerView, didSelectRowAt index: Int) { 89 | print("select at: \(index)") 90 | } 91 | 92 | } 93 | 94 | 95 | ``` 96 | 97 | ## License 98 | 99 | CycleBanner is released under the Apache-2.0 license. See LICENSE for details. 100 | 101 | -------------------------------------------------------------------------------- /Example/Example/CustomCycleBannerViewCell.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /CycleBanner.xcodeproj/xcuserdata/jiar.xcuserdatad/xcschemes/CycleBanner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 34 | 40 | 41 | 42 | 43 | 44 | 50 | 51 | 52 | 53 | 54 | 55 | 66 | 67 | 73 | 74 | 75 | 76 | 77 | 78 | 84 | 85 | 91 | 92 | 93 | 94 | 96 | 97 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /Example/Example.xcodeproj/xcuserdata/jiar.xcuserdatad/xcschemes/Example.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 34 | 40 | 41 | 42 | 44 | 50 | 51 | 52 | 53 | 54 | 60 | 61 | 62 | 63 | 64 | 65 | 76 | 78 | 84 | 85 | 86 | 87 | 88 | 89 | 95 | 97 | 103 | 104 | 105 | 106 | 108 | 109 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /Example/Example/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 35 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /CycleBanner.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 80678A651FE7B64900F4174D /* CycleBanner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80678A641FE7B64900F4174D /* CycleBanner.swift */; }; 11 | 80B218201FE7B1B50049A3F8 /* CycleBanner.h in Headers */ = {isa = PBXBuildFile; fileRef = 80B2181E1FE7B1B50049A3F8 /* CycleBanner.h */; settings = {ATTRIBUTES = (Public, ); }; }; 12 | 80B218211FE7B1B50049A3F8 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 80B2181F1FE7B1B50049A3F8 /* Info.plist */; }; 13 | 80B218291FE7B1E30049A3F8 /* CycleBannerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80B218241FE7B1DA0049A3F8 /* CycleBannerTests.swift */; }; 14 | 80B2182A1FE7B1E60049A3F8 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 80B218251FE7B1DA0049A3F8 /* Info.plist */; }; 15 | 80B2182C1FE7B2510049A3F8 /* CycleBanner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 80B218221FE7B1C50049A3F8 /* CycleBanner.framework */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXContainerItemProxy section */ 19 | 80B2180E1FE7B1850049A3F8 /* PBXContainerItemProxy */ = { 20 | isa = PBXContainerItemProxy; 21 | containerPortal = 80B217FA1FE7B1840049A3F8 /* Project object */; 22 | proxyType = 1; 23 | remoteGlobalIDString = 80B218021FE7B1840049A3F8; 24 | remoteInfo = CycleBanner; 25 | }; 26 | /* End PBXContainerItemProxy section */ 27 | 28 | /* Begin PBXFileReference section */ 29 | 80678A641FE7B64900F4174D /* CycleBanner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CycleBanner.swift; sourceTree = ""; }; 30 | 80B2181E1FE7B1B50049A3F8 /* CycleBanner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CycleBanner.h; sourceTree = ""; }; 31 | 80B2181F1FE7B1B50049A3F8 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 32 | 80B218221FE7B1C50049A3F8 /* CycleBanner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CycleBanner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 33 | 80B218241FE7B1DA0049A3F8 /* CycleBannerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CycleBannerTests.swift; sourceTree = ""; }; 34 | 80B218251FE7B1DA0049A3F8 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 35 | 80B218271FE7B1DB0049A3F8 /* CycleBannerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CycleBannerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 36 | /* End PBXFileReference section */ 37 | 38 | /* Begin PBXFrameworksBuildPhase section */ 39 | 80B217FF1FE7B1840049A3F8 /* Frameworks */ = { 40 | isa = PBXFrameworksBuildPhase; 41 | buildActionMask = 2147483647; 42 | files = ( 43 | ); 44 | runOnlyForDeploymentPostprocessing = 0; 45 | }; 46 | 80B218091FE7B1850049A3F8 /* Frameworks */ = { 47 | isa = PBXFrameworksBuildPhase; 48 | buildActionMask = 2147483647; 49 | files = ( 50 | 80B2182C1FE7B2510049A3F8 /* CycleBanner.framework in Frameworks */, 51 | ); 52 | runOnlyForDeploymentPostprocessing = 0; 53 | }; 54 | /* End PBXFrameworksBuildPhase section */ 55 | 56 | /* Begin PBXGroup section */ 57 | 80B217F91FE7B1840049A3F8 = { 58 | isa = PBXGroup; 59 | children = ( 60 | 80B2181D1FE7B1B50049A3F8 /* CycleBanner */, 61 | 80B218231FE7B1DA0049A3F8 /* CycleBannerTests */, 62 | 80B218221FE7B1C50049A3F8 /* CycleBanner.framework */, 63 | 80B218271FE7B1DB0049A3F8 /* CycleBannerTests.xctest */, 64 | 80B2182B1FE7B2510049A3F8 /* Frameworks */, 65 | ); 66 | sourceTree = ""; 67 | }; 68 | 80B2181D1FE7B1B50049A3F8 /* CycleBanner */ = { 69 | isa = PBXGroup; 70 | children = ( 71 | 80B2181F1FE7B1B50049A3F8 /* Info.plist */, 72 | 80B2181E1FE7B1B50049A3F8 /* CycleBanner.h */, 73 | 80678A641FE7B64900F4174D /* CycleBanner.swift */, 74 | ); 75 | path = CycleBanner; 76 | sourceTree = ""; 77 | }; 78 | 80B218231FE7B1DA0049A3F8 /* CycleBannerTests */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | 80B218241FE7B1DA0049A3F8 /* CycleBannerTests.swift */, 82 | 80B218251FE7B1DA0049A3F8 /* Info.plist */, 83 | ); 84 | path = CycleBannerTests; 85 | sourceTree = ""; 86 | }; 87 | 80B2182B1FE7B2510049A3F8 /* Frameworks */ = { 88 | isa = PBXGroup; 89 | children = ( 90 | ); 91 | name = Frameworks; 92 | sourceTree = ""; 93 | }; 94 | /* End PBXGroup section */ 95 | 96 | /* Begin PBXHeadersBuildPhase section */ 97 | 80B218001FE7B1840049A3F8 /* Headers */ = { 98 | isa = PBXHeadersBuildPhase; 99 | buildActionMask = 2147483647; 100 | files = ( 101 | 80B218201FE7B1B50049A3F8 /* CycleBanner.h in Headers */, 102 | ); 103 | runOnlyForDeploymentPostprocessing = 0; 104 | }; 105 | /* End PBXHeadersBuildPhase section */ 106 | 107 | /* Begin PBXNativeTarget section */ 108 | 80B218021FE7B1840049A3F8 /* CycleBanner */ = { 109 | isa = PBXNativeTarget; 110 | buildConfigurationList = 80B218171FE7B1850049A3F8 /* Build configuration list for PBXNativeTarget "CycleBanner" */; 111 | buildPhases = ( 112 | 80B217FE1FE7B1840049A3F8 /* Sources */, 113 | 80B217FF1FE7B1840049A3F8 /* Frameworks */, 114 | 80B218001FE7B1840049A3F8 /* Headers */, 115 | 80B218011FE7B1840049A3F8 /* Resources */, 116 | ); 117 | buildRules = ( 118 | ); 119 | dependencies = ( 120 | ); 121 | name = CycleBanner; 122 | productName = CycleBanner; 123 | productReference = 80B218221FE7B1C50049A3F8 /* CycleBanner.framework */; 124 | productType = "com.apple.product-type.framework"; 125 | }; 126 | 80B2180B1FE7B1850049A3F8 /* CycleBannerTests */ = { 127 | isa = PBXNativeTarget; 128 | buildConfigurationList = 80B2181A1FE7B1850049A3F8 /* Build configuration list for PBXNativeTarget "CycleBannerTests" */; 129 | buildPhases = ( 130 | 80B218081FE7B1850049A3F8 /* Sources */, 131 | 80B218091FE7B1850049A3F8 /* Frameworks */, 132 | 80B2180A1FE7B1850049A3F8 /* Resources */, 133 | ); 134 | buildRules = ( 135 | ); 136 | dependencies = ( 137 | 80B2180F1FE7B1850049A3F8 /* PBXTargetDependency */, 138 | ); 139 | name = CycleBannerTests; 140 | productName = CycleBannerTests; 141 | productReference = 80B218271FE7B1DB0049A3F8 /* CycleBannerTests.xctest */; 142 | productType = "com.apple.product-type.bundle.unit-test"; 143 | }; 144 | /* End PBXNativeTarget section */ 145 | 146 | /* Begin PBXProject section */ 147 | 80B217FA1FE7B1840049A3F8 /* Project object */ = { 148 | isa = PBXProject; 149 | attributes = { 150 | LastSwiftUpdateCheck = 0920; 151 | LastUpgradeCheck = 0920; 152 | ORGANIZATIONNAME = Jiar; 153 | TargetAttributes = { 154 | 80B218021FE7B1840049A3F8 = { 155 | CreatedOnToolsVersion = 9.2; 156 | LastSwiftMigration = 0920; 157 | ProvisioningStyle = Automatic; 158 | }; 159 | 80B2180B1FE7B1850049A3F8 = { 160 | CreatedOnToolsVersion = 9.2; 161 | ProvisioningStyle = Automatic; 162 | }; 163 | }; 164 | }; 165 | buildConfigurationList = 80B217FD1FE7B1840049A3F8 /* Build configuration list for PBXProject "CycleBanner" */; 166 | compatibilityVersion = "Xcode 8.0"; 167 | developmentRegion = en; 168 | hasScannedForEncodings = 0; 169 | knownRegions = ( 170 | en, 171 | ); 172 | mainGroup = 80B217F91FE7B1840049A3F8; 173 | productRefGroup = 80B217F91FE7B1840049A3F8; 174 | projectDirPath = ""; 175 | projectRoot = ""; 176 | targets = ( 177 | 80B218021FE7B1840049A3F8 /* CycleBanner */, 178 | 80B2180B1FE7B1850049A3F8 /* CycleBannerTests */, 179 | ); 180 | }; 181 | /* End PBXProject section */ 182 | 183 | /* Begin PBXResourcesBuildPhase section */ 184 | 80B218011FE7B1840049A3F8 /* Resources */ = { 185 | isa = PBXResourcesBuildPhase; 186 | buildActionMask = 2147483647; 187 | files = ( 188 | 80B218211FE7B1B50049A3F8 /* Info.plist in Resources */, 189 | ); 190 | runOnlyForDeploymentPostprocessing = 0; 191 | }; 192 | 80B2180A1FE7B1850049A3F8 /* Resources */ = { 193 | isa = PBXResourcesBuildPhase; 194 | buildActionMask = 2147483647; 195 | files = ( 196 | 80B2182A1FE7B1E60049A3F8 /* Info.plist in Resources */, 197 | ); 198 | runOnlyForDeploymentPostprocessing = 0; 199 | }; 200 | /* End PBXResourcesBuildPhase section */ 201 | 202 | /* Begin PBXSourcesBuildPhase section */ 203 | 80B217FE1FE7B1840049A3F8 /* Sources */ = { 204 | isa = PBXSourcesBuildPhase; 205 | buildActionMask = 2147483647; 206 | files = ( 207 | 80678A651FE7B64900F4174D /* CycleBanner.swift in Sources */, 208 | ); 209 | runOnlyForDeploymentPostprocessing = 0; 210 | }; 211 | 80B218081FE7B1850049A3F8 /* Sources */ = { 212 | isa = PBXSourcesBuildPhase; 213 | buildActionMask = 2147483647; 214 | files = ( 215 | 80B218291FE7B1E30049A3F8 /* CycleBannerTests.swift in Sources */, 216 | ); 217 | runOnlyForDeploymentPostprocessing = 0; 218 | }; 219 | /* End PBXSourcesBuildPhase section */ 220 | 221 | /* Begin PBXTargetDependency section */ 222 | 80B2180F1FE7B1850049A3F8 /* PBXTargetDependency */ = { 223 | isa = PBXTargetDependency; 224 | target = 80B218021FE7B1840049A3F8 /* CycleBanner */; 225 | targetProxy = 80B2180E1FE7B1850049A3F8 /* PBXContainerItemProxy */; 226 | }; 227 | /* End PBXTargetDependency section */ 228 | 229 | /* Begin XCBuildConfiguration section */ 230 | 80B218151FE7B1850049A3F8 /* Debug */ = { 231 | isa = XCBuildConfiguration; 232 | buildSettings = { 233 | ALWAYS_SEARCH_USER_PATHS = NO; 234 | CLANG_ANALYZER_NONNULL = YES; 235 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 236 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 237 | CLANG_CXX_LIBRARY = "libc++"; 238 | CLANG_ENABLE_MODULES = YES; 239 | CLANG_ENABLE_OBJC_ARC = YES; 240 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 241 | CLANG_WARN_BOOL_CONVERSION = YES; 242 | CLANG_WARN_COMMA = YES; 243 | CLANG_WARN_CONSTANT_CONVERSION = YES; 244 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 245 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 246 | CLANG_WARN_EMPTY_BODY = YES; 247 | CLANG_WARN_ENUM_CONVERSION = YES; 248 | CLANG_WARN_INFINITE_RECURSION = YES; 249 | CLANG_WARN_INT_CONVERSION = YES; 250 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 251 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 252 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 253 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 254 | CLANG_WARN_STRICT_PROTOTYPES = YES; 255 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 256 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 257 | CLANG_WARN_UNREACHABLE_CODE = YES; 258 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 259 | CODE_SIGN_IDENTITY = "iPhone Developer"; 260 | COPY_PHASE_STRIP = NO; 261 | CURRENT_PROJECT_VERSION = 1; 262 | DEBUG_INFORMATION_FORMAT = dwarf; 263 | ENABLE_STRICT_OBJC_MSGSEND = YES; 264 | ENABLE_TESTABILITY = YES; 265 | GCC_C_LANGUAGE_STANDARD = gnu11; 266 | GCC_DYNAMIC_NO_PIC = NO; 267 | GCC_NO_COMMON_BLOCKS = YES; 268 | GCC_OPTIMIZATION_LEVEL = 0; 269 | GCC_PREPROCESSOR_DEFINITIONS = ( 270 | "DEBUG=1", 271 | "$(inherited)", 272 | ); 273 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 274 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 275 | GCC_WARN_UNDECLARED_SELECTOR = YES; 276 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 277 | GCC_WARN_UNUSED_FUNCTION = YES; 278 | GCC_WARN_UNUSED_VARIABLE = YES; 279 | IPHONEOS_DEPLOYMENT_TARGET = 11.2; 280 | MTL_ENABLE_DEBUG_INFO = YES; 281 | ONLY_ACTIVE_ARCH = YES; 282 | SDKROOT = iphoneos; 283 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 284 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 285 | VERSIONING_SYSTEM = "apple-generic"; 286 | VERSION_INFO_PREFIX = ""; 287 | }; 288 | name = Debug; 289 | }; 290 | 80B218161FE7B1850049A3F8 /* Release */ = { 291 | isa = XCBuildConfiguration; 292 | buildSettings = { 293 | ALWAYS_SEARCH_USER_PATHS = NO; 294 | CLANG_ANALYZER_NONNULL = YES; 295 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 296 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 297 | CLANG_CXX_LIBRARY = "libc++"; 298 | CLANG_ENABLE_MODULES = YES; 299 | CLANG_ENABLE_OBJC_ARC = YES; 300 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 301 | CLANG_WARN_BOOL_CONVERSION = YES; 302 | CLANG_WARN_COMMA = YES; 303 | CLANG_WARN_CONSTANT_CONVERSION = YES; 304 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 305 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 306 | CLANG_WARN_EMPTY_BODY = YES; 307 | CLANG_WARN_ENUM_CONVERSION = YES; 308 | CLANG_WARN_INFINITE_RECURSION = YES; 309 | CLANG_WARN_INT_CONVERSION = YES; 310 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 311 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 312 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 313 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 314 | CLANG_WARN_STRICT_PROTOTYPES = YES; 315 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 316 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 317 | CLANG_WARN_UNREACHABLE_CODE = YES; 318 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 319 | CODE_SIGN_IDENTITY = "iPhone Developer"; 320 | COPY_PHASE_STRIP = NO; 321 | CURRENT_PROJECT_VERSION = 1; 322 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 323 | ENABLE_NS_ASSERTIONS = NO; 324 | ENABLE_STRICT_OBJC_MSGSEND = YES; 325 | GCC_C_LANGUAGE_STANDARD = gnu11; 326 | GCC_NO_COMMON_BLOCKS = YES; 327 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 328 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 329 | GCC_WARN_UNDECLARED_SELECTOR = YES; 330 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 331 | GCC_WARN_UNUSED_FUNCTION = YES; 332 | GCC_WARN_UNUSED_VARIABLE = YES; 333 | IPHONEOS_DEPLOYMENT_TARGET = 11.2; 334 | MTL_ENABLE_DEBUG_INFO = NO; 335 | SDKROOT = iphoneos; 336 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 337 | VALIDATE_PRODUCT = YES; 338 | VERSIONING_SYSTEM = "apple-generic"; 339 | VERSION_INFO_PREFIX = ""; 340 | }; 341 | name = Release; 342 | }; 343 | 80B218181FE7B1850049A3F8 /* Debug */ = { 344 | isa = XCBuildConfiguration; 345 | buildSettings = { 346 | CLANG_ENABLE_MODULES = YES; 347 | CODE_SIGN_IDENTITY = ""; 348 | CODE_SIGN_STYLE = Automatic; 349 | DEFINES_MODULE = YES; 350 | DYLIB_COMPATIBILITY_VERSION = 1; 351 | DYLIB_CURRENT_VERSION = 1; 352 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 353 | INFOPLIST_FILE = CycleBanner/Info.plist; 354 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 355 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 356 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 357 | PRODUCT_BUNDLE_IDENTIFIER = Jiar.CycleBanner; 358 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 359 | SKIP_INSTALL = YES; 360 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 361 | SWIFT_VERSION = 4.0; 362 | TARGETED_DEVICE_FAMILY = "1,2"; 363 | }; 364 | name = Debug; 365 | }; 366 | 80B218191FE7B1850049A3F8 /* Release */ = { 367 | isa = XCBuildConfiguration; 368 | buildSettings = { 369 | CLANG_ENABLE_MODULES = YES; 370 | CODE_SIGN_IDENTITY = ""; 371 | CODE_SIGN_STYLE = Automatic; 372 | DEFINES_MODULE = YES; 373 | DYLIB_COMPATIBILITY_VERSION = 1; 374 | DYLIB_CURRENT_VERSION = 1; 375 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 376 | INFOPLIST_FILE = CycleBanner/Info.plist; 377 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 378 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 379 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 380 | PRODUCT_BUNDLE_IDENTIFIER = Jiar.CycleBanner; 381 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 382 | SKIP_INSTALL = YES; 383 | SWIFT_VERSION = 4.0; 384 | TARGETED_DEVICE_FAMILY = "1,2"; 385 | }; 386 | name = Release; 387 | }; 388 | 80B2181B1FE7B1850049A3F8 /* Debug */ = { 389 | isa = XCBuildConfiguration; 390 | buildSettings = { 391 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 392 | CODE_SIGN_STYLE = Automatic; 393 | INFOPLIST_FILE = CycleBannerTests/Info.plist; 394 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 395 | PRODUCT_BUNDLE_IDENTIFIER = Jiar.CycleBannerTests; 396 | PRODUCT_NAME = "$(TARGET_NAME)"; 397 | SWIFT_VERSION = 4.0; 398 | TARGETED_DEVICE_FAMILY = "1,2"; 399 | }; 400 | name = Debug; 401 | }; 402 | 80B2181C1FE7B1850049A3F8 /* Release */ = { 403 | isa = XCBuildConfiguration; 404 | buildSettings = { 405 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 406 | CODE_SIGN_STYLE = Automatic; 407 | INFOPLIST_FILE = CycleBannerTests/Info.plist; 408 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 409 | PRODUCT_BUNDLE_IDENTIFIER = Jiar.CycleBannerTests; 410 | PRODUCT_NAME = "$(TARGET_NAME)"; 411 | SWIFT_VERSION = 4.0; 412 | TARGETED_DEVICE_FAMILY = "1,2"; 413 | }; 414 | name = Release; 415 | }; 416 | /* End XCBuildConfiguration section */ 417 | 418 | /* Begin XCConfigurationList section */ 419 | 80B217FD1FE7B1840049A3F8 /* Build configuration list for PBXProject "CycleBanner" */ = { 420 | isa = XCConfigurationList; 421 | buildConfigurations = ( 422 | 80B218151FE7B1850049A3F8 /* Debug */, 423 | 80B218161FE7B1850049A3F8 /* Release */, 424 | ); 425 | defaultConfigurationIsVisible = 0; 426 | defaultConfigurationName = Release; 427 | }; 428 | 80B218171FE7B1850049A3F8 /* Build configuration list for PBXNativeTarget "CycleBanner" */ = { 429 | isa = XCConfigurationList; 430 | buildConfigurations = ( 431 | 80B218181FE7B1850049A3F8 /* Debug */, 432 | 80B218191FE7B1850049A3F8 /* Release */, 433 | ); 434 | defaultConfigurationIsVisible = 0; 435 | defaultConfigurationName = Release; 436 | }; 437 | 80B2181A1FE7B1850049A3F8 /* Build configuration list for PBXNativeTarget "CycleBannerTests" */ = { 438 | isa = XCConfigurationList; 439 | buildConfigurations = ( 440 | 80B2181B1FE7B1850049A3F8 /* Debug */, 441 | 80B2181C1FE7B1850049A3F8 /* Release */, 442 | ); 443 | defaultConfigurationIsVisible = 0; 444 | defaultConfigurationName = Release; 445 | }; 446 | /* End XCConfigurationList section */ 447 | }; 448 | rootObject = 80B217FA1FE7B1840049A3F8 /* Project object */; 449 | } 450 | -------------------------------------------------------------------------------- /CycleBanner/CycleBanner.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CycleBanner.swift 3 | // CycleBanner 4 | // 5 | // Created by Jiar on 2017/12/18. 6 | // Copyright © 2017年 Jiar. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public protocol CycleBannerViewDelegate: class { 12 | 13 | func cycleBannerView(_ cycleBannerView: CycleBannerView, didSelectRowAt index: Int) 14 | 15 | } 16 | 17 | public protocol CycleBannerViewDataSource: class { 18 | 19 | func numberOfBanners(in cycleBannerView: CycleBannerView) -> Int 20 | func cycleBannerView(_ cycleBannerView: CycleBannerView, cellForRowAt index: Int) -> CycleBannerViewCell 21 | 22 | } 23 | 24 | open class CycleBannerViewCell: UIView { 25 | 26 | fileprivate var identifier: String? 27 | fileprivate var selectClosure: (() -> Void)? 28 | 29 | @objc fileprivate func selectAction() { 30 | selectClosure?() 31 | } 32 | 33 | } 34 | 35 | open class CycleBannerView: UIView { 36 | 37 | /// the width for every item 38 | /// modifying this value automatically invokes the reloadData() method 39 | open var rowWidth: CGFloat = 0 { 40 | didSet { 41 | rowWidth.round() 42 | reloadData() 43 | } 44 | } 45 | /// the space between items 46 | /// modifying this value automatically invokes the reloadData() method 47 | open var rowSpace: CGFloat = 0 { 48 | didSet { 49 | rowSpace.round() 50 | reloadData() 51 | } 52 | } 53 | /// whether to enable automatic scrolling, default is true 54 | open var autoSlide = true { 55 | didSet { 56 | autoSlideIfNeeded() 57 | } 58 | } 59 | /// whether to hide the bottom pageControl display, default is false 60 | open var isHiddenPageControl: Bool { 61 | get { 62 | return pageControl.isHidden 63 | } 64 | set { 65 | pageControl.isHidden = newValue 66 | } 67 | } 68 | /// automatic scrolling time interval, default is 5 69 | /// it must be set before the autoSlide property is set to true 70 | open var timeInterval: TimeInterval = 5 71 | 72 | open weak var delegate: CycleBannerViewDelegate? 73 | open weak var dataSource: CycleBannerViewDataSource? 74 | 75 | enum InitMethod { 76 | case `default` 77 | case coder(NSCoder) 78 | case frame(CGRect) 79 | } 80 | 81 | private let pageControl: UIPageControl 82 | private let scrollView: UIScrollView 83 | private var pageControlWidthConstraint: NSLayoutConstraint? 84 | private var scrollViewLeftConstraint: NSLayoutConstraint? 85 | private var scrollViewRightConstraint: NSLayoutConstraint? 86 | private var autoSlideTimer: Timer? 87 | 88 | private var hasInit = false 89 | 90 | public convenience init() { 91 | self.init(.default) 92 | } 93 | 94 | public override convenience init(frame: CGRect) { 95 | self.init(.frame(frame)) 96 | } 97 | 98 | public required convenience init(coder aDecoder: NSCoder) { 99 | self.init(.coder(aDecoder)) 100 | } 101 | 102 | private init(_ initMethod: InitMethod) { 103 | scrollView = UIScrollView() 104 | scrollView.translatesAutoresizingMaskIntoConstraints = false 105 | pageControl = UIPageControl() 106 | pageControl.translatesAutoresizingMaskIntoConstraints = false 107 | switch initMethod { 108 | case .default: 109 | super.init(frame: CGRect.zero) 110 | case let .coder(coder): 111 | super.init(coder: coder)! 112 | case let .frame(frame): 113 | super.init(frame: frame) 114 | } 115 | rowSpace = 10 116 | rowWidth = width-2*(rowSpace+10) 117 | translatesAutoresizingMaskIntoConstraints = false 118 | addSubview(scrollView) 119 | addSubview(pageControl) 120 | setupScrollView() 121 | setupPageControl() 122 | hasInit = true 123 | } 124 | 125 | private func setupScrollView() { 126 | scrollView.delegate = self 127 | scrollView.bounces = false 128 | scrollView.isPagingEnabled = true 129 | scrollView.decelerationRate = 0 130 | scrollView.showsHorizontalScrollIndicator = false 131 | scrollView.showsVerticalScrollIndicator = false 132 | scrollView.layer.masksToBounds = false 133 | scrollView.topAnchor.constraint(equalTo: topAnchor).isActive = true 134 | scrollView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true 135 | scrollViewLeftConstraint = scrollView.leftAnchor.constraint(equalTo: leftAnchor, constant: itemOutSpace) 136 | scrollViewRightConstraint = scrollView.rightAnchor.constraint(equalTo: rightAnchor, constant: -itemOutSpace) 137 | scrollViewLeftConstraint!.isActive = true 138 | scrollViewRightConstraint!.isActive = true 139 | } 140 | 141 | private func setupPageControl() { 142 | pageControl.isUserInteractionEnabled = false 143 | var pageControlWidth = pageControl.size(forNumberOfPages: pageControl.numberOfPages).width 144 | if pageControlWidth > width { 145 | pageControlWidth = width 146 | } 147 | pageControlWidthConstraint = pageControl.widthAnchor.constraint(equalToConstant: pageControlWidth) 148 | pageControlWidthConstraint?.isActive = true 149 | pageControl.heightAnchor.constraint(equalToConstant: pageControl.bounds.height).isActive = true 150 | pageControl.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -10).isActive = true 151 | pageControl.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true 152 | } 153 | 154 | private func autoSlideIfNeeded() { 155 | if autoSlide { 156 | enableAutoSlide() 157 | } else { 158 | disableAutoSlide() 159 | } 160 | } 161 | 162 | private func enableAutoSlide() { 163 | guard autoSlide, autoSlideTimer == nil else { 164 | return 165 | } 166 | autoSlideTimer = Timer.scheduledTimer(timeInterval: timeInterval, target: self, selector: #selector(CycleBannerView.autoSlideAction), userInfo: nil, repeats: true) 167 | } 168 | 169 | private func disableAutoSlide() { 170 | guard autoSlide, autoSlideTimer != nil else { 171 | return 172 | } 173 | autoSlideTimer?.invalidate() 174 | autoSlideTimer = nil 175 | } 176 | 177 | @objc private func autoSlideAction() { 178 | guard pageControl.numberOfPages > 1 else { 179 | return 180 | } 181 | scrollView.setContentOffset(CGPoint(x: showCellMinX+2*itemWidth-rowSpace/2, y: scrollView.contentOffset.y), animated: true) 182 | } 183 | 184 | open override func layoutSubviews() { 185 | super.layoutSubviews() 186 | scrollView.contentSize = CGSize(width: CGFloat.greatestFiniteMagnitude, height: scrollView.bounds.height) 187 | } 188 | 189 | open func reloadData() { 190 | guard hasInit, let dataSource = dataSource else { 191 | return 192 | } 193 | disableAutoSlide() 194 | 195 | scrollViewLeftConstraint?.isActive = false 196 | scrollViewRightConstraint?.isActive = false 197 | scrollViewLeftConstraint = scrollView.leftAnchor.constraint(equalTo: leftAnchor, constant: itemOutSpace) 198 | scrollViewRightConstraint = scrollView.rightAnchor.constraint(equalTo: rightAnchor, constant: -itemOutSpace) 199 | scrollViewLeftConstraint!.isActive = true 200 | scrollViewRightConstraint!.isActive = true 201 | 202 | let numberOfBanners = dataSource.numberOfBanners(in: self) 203 | pageControl.numberOfPages = numberOfBanners 204 | pageControlWidthConstraint?.isActive = false 205 | var pageControlWidth = pageControl.size(forNumberOfPages: pageControl.numberOfPages).width 206 | if pageControlWidth > width { 207 | pageControlWidth = width 208 | } 209 | pageControlWidthConstraint = pageControl.widthAnchor.constraint(equalToConstant: pageControlWidth) 210 | pageControlWidthConstraint?.isActive = true 211 | scrollView.isScrollEnabled = numberOfBanners > 1 212 | pageControl.currentPage = 0 213 | layoutIfNeeded() 214 | 215 | for identifier in cellOnShowQueue.keys { 216 | if let cells = cellOnShowQueue[identifier] { 217 | let indexs = (0 ..< cells.count).sorted(by: >) 218 | for index in indexs { 219 | if let cell = cellOnShowQueue[identifier]?.remove(at: index) { 220 | cell.frame.origin = .zero 221 | cell.removeFromSuperview() 222 | if reuseCellQueue[identifier] == nil { 223 | reuseCellQueue[identifier] = [] 224 | } 225 | reuseCellQueue[identifier]!.append(cell) 226 | } 227 | } 228 | } 229 | } 230 | 231 | guard numberOfBanners > 0 else { 232 | return 233 | } 234 | let currentPoint = initCellPoint 235 | scrollView.contentOffset = CGPoint(x: currentPoint.x-rowSpace/2, y: currentPoint.y) 236 | let currentCell = dataSource.cycleBannerView(self, cellForRowAt: 0) 237 | setSelectCellClosure(currentCell, index: 0) 238 | currentCell.frame = CGRect(origin: currentPoint, size: CGSize(width: rowWidth, height: bounds.height)) 239 | scrollView.addSubview(currentCell) 240 | showCellMinX = currentCell.frame.minX 241 | showCellMaxX = currentCell.frame.maxX 242 | addCellToShowQueue(currentCell) 243 | 244 | guard numberOfBanners > 1 else { 245 | return 246 | } 247 | let leftPoint = CGPoint(x: currentPoint.x-itemWidth, y: currentPoint.y) 248 | let leftIndex = getIndexByContentOffset(leftPoint) 249 | let leftCell = dataSource.cycleBannerView(self, cellForRowAt: leftIndex) 250 | setSelectCellClosure(leftCell, index: leftIndex) 251 | leftCell.frame = CGRect(origin: leftPoint, size: CGSize(width: rowWidth, height: bounds.height)) 252 | scrollView.addSubview(leftCell) 253 | showCellMinX = leftCell.frame.minX 254 | addCellToShowQueue(leftCell) 255 | 256 | let rightPoint = CGPoint(x: currentPoint.x+itemWidth, y: currentPoint.y) 257 | let rightIndex = getIndexByContentOffset(rightPoint) 258 | let rightCell = dataSource.cycleBannerView(self, cellForRowAt: rightIndex) 259 | setSelectCellClosure(rightCell, index: rightIndex) 260 | rightCell.frame = CGRect(origin: rightPoint, size: CGSize(width: rowWidth, height: bounds.height)) 261 | scrollView.addSubview(rightCell) 262 | showCellMaxX = rightCell.frame.maxX 263 | addCellToShowQueue(rightCell) 264 | 265 | autoSlideIfNeeded() 266 | } 267 | 268 | private var width: CGFloat { 269 | return bounds.width 270 | } 271 | private var space: CGFloat { 272 | return (width-rowWidth-2*rowSpace)/2 273 | } 274 | private var itemWidth: CGFloat { 275 | return rowWidth+rowSpace 276 | } 277 | private var itemOutSpace: CGFloat { 278 | return rowSpace/2+space 279 | } 280 | private var initCellPoint: CGPoint { 281 | return CGPoint(x: CGFloat(10000)*CGFloat(pageControl.numberOfPages)*itemWidth+rowSpace/2, y: 0) 282 | } 283 | private var showCellMinX: CGFloat = 0 284 | private var showCellMaxX: CGFloat = 0 285 | 286 | private var isNib = false 287 | private var reuseCellNibQueue: [String: UINib] = [:] 288 | private var reuseCellClassQueue: [String: CycleBannerViewCell.Type] = [:] 289 | private var cellOnShowQueue: [String: [CycleBannerViewCell]] = [:] 290 | private var reuseCellQueue: [String: [CycleBannerViewCell]] = [:] 291 | 292 | public func register(_ nib: UINib?, forCellReuseIdentifier identifier: String) { 293 | isNib = true 294 | if let nib = nib { 295 | reuseCellNibQueue[identifier] = nib 296 | } else { 297 | reuseCellNibQueue.removeValue(forKey: identifier) 298 | } 299 | } 300 | 301 | public func register(_ cellClass: CycleBannerViewCell.Type?, forCellReuseIdentifier identifier: String) { 302 | isNib = false 303 | if let cellClass = cellClass { 304 | reuseCellClassQueue[identifier] = cellClass 305 | } else { 306 | reuseCellClassQueue.removeValue(forKey: identifier) 307 | } 308 | } 309 | 310 | public func dequeueReusableCell(withIdentifier identifier: String) -> CycleBannerViewCell { 311 | var cell: CycleBannerViewCell! 312 | if reuseCellQueue[identifier] == nil { 313 | reuseCellQueue[identifier] = [] 314 | } 315 | if let reuseCell = reuseCellQueue[identifier]!.popLast() { 316 | cell = reuseCell 317 | } else { 318 | if isNib { 319 | if let nib = reuseCellNibQueue[identifier] { 320 | cell = nib.instantiate(withOwner: nil, options: nil)[0] as! CycleBannerViewCell 321 | } else { 322 | assert(false, "not register nib") 323 | } 324 | } else { 325 | if let cellClass = reuseCellClassQueue[identifier] { 326 | cell = cellClass.init() 327 | } else { 328 | assert(false, "not register class") 329 | } 330 | } 331 | } 332 | cell.identifier = identifier 333 | return cell 334 | } 335 | 336 | fileprivate func showCellsByContentOffset(_ contentOffset: CGPoint) { 337 | guard let dataSource = dataSource else { 338 | return 339 | } 340 | let screenLeft = contentOffset.x-itemOutSpace 341 | let screenRight = screenLeft+width+itemOutSpace 342 | if screenLeft < showCellMinX-rowSpace { 343 | let newLeftCellX = showCellMinX-itemWidth 344 | let index = getIndexByContentOffset(CGPoint(x: newLeftCellX, y: initCellPoint.y)) 345 | let newLeftCell = dataSource.cycleBannerView(self, cellForRowAt: index) 346 | setSelectCellClosure(newLeftCell, index: index) 347 | newLeftCell.frame = CGRect(origin: CGPoint(x: newLeftCellX, y: initCellPoint.y), size: CGSize(width: rowWidth, height: bounds.height)) 348 | scrollView.addSubview(newLeftCell) 349 | addCellToShowQueue(newLeftCell) 350 | showCellMinX = newLeftCell.frame.minX 351 | } 352 | if showCellMaxX+rowSpace < screenRight { 353 | let newRightCellX = showCellMaxX+rowSpace 354 | let index = getIndexByContentOffset(CGPoint(x: newRightCellX, y: initCellPoint.y)) 355 | let newRightCell = dataSource.cycleBannerView(self, cellForRowAt: index) 356 | setSelectCellClosure(newRightCell, index: index) 357 | newRightCell.frame = CGRect(origin: CGPoint(x: newRightCellX, y: initCellPoint.y), size: CGSize(width: rowWidth, height: bounds.height)) 358 | scrollView.addSubview(newRightCell) 359 | addCellToShowQueue(newRightCell) 360 | showCellMaxX = newRightCell.frame.maxX 361 | } 362 | } 363 | 364 | fileprivate func showCellToReuseQueue(_ contentOffset: CGPoint) { 365 | let screenLeft = contentOffset.x-itemOutSpace 366 | let screenRight = screenLeft+width+itemOutSpace 367 | var isModify = false 368 | for identifier in cellOnShowQueue.keys { 369 | if let cells = cellOnShowQueue[identifier] { 370 | var indexs: [Int] = [] 371 | for (index, cell) in cells.enumerated() { 372 | let minX = cell.frame.minX 373 | let maxX = cell.frame.maxX 374 | guard (screenLeft <= minX && minX <= screenRight) || (screenLeft <= maxX && maxX <= screenRight) else { 375 | indexs.append(index) 376 | continue 377 | } 378 | } 379 | indexs = indexs.sorted(by: > ) 380 | for index in indexs { 381 | isModify = true 382 | if let cell = cellOnShowQueue[identifier]?.remove(at: index) { 383 | cell.frame.origin = .zero 384 | cell.removeFromSuperview() 385 | if reuseCellQueue[identifier] == nil { 386 | reuseCellQueue[identifier] = [] 387 | } 388 | reuseCellQueue[identifier]!.append(cell) 389 | } 390 | } 391 | } 392 | } 393 | guard isModify else { 394 | return 395 | } 396 | for cells in cellOnShowQueue.values { 397 | guard cells.count > 0 else { 398 | continue 399 | } 400 | var minX: CGFloat = cells.first!.frame.minX 401 | var maxX: CGFloat = cells.first!.frame.maxX 402 | for cell in cells { 403 | if cell.frame.minX < minX { 404 | minX = cell.frame.minX 405 | } 406 | if cell.frame.maxX > maxX { 407 | maxX = cell.frame.maxX 408 | } 409 | } 410 | showCellMinX = minX 411 | showCellMaxX = maxX 412 | } 413 | } 414 | 415 | fileprivate func setCurrentPageByContentOffset(_ contentOffset: CGPoint) { 416 | let index = getIndexByContentOffset(contentOffset) 417 | pageControl.currentPage = index 418 | } 419 | 420 | private func getIndexByContentOffset(_ contentOffset: CGPoint) -> Int { 421 | let offsetInWheel = contentOffset.x.truncatingRemainder(dividingBy: CGFloat(pageControl.numberOfPages)*itemWidth) 422 | var index = Int(offsetInWheel/itemWidth) 423 | index = index % pageControl.numberOfPages 424 | return index 425 | } 426 | 427 | private func setSelectCellClosure(_ cell: CycleBannerViewCell, index: Int) { 428 | cell.addGestureRecognizer(UITapGestureRecognizer(target: cell, action: #selector(CycleBannerViewCell.selectAction))) 429 | cell.selectClosure = { 430 | self.delegate?.cycleBannerView(self, didSelectRowAt: index) 431 | } 432 | } 433 | 434 | private func addCellToShowQueue(_ cell: CycleBannerViewCell) { 435 | if let identifier = cell.identifier { 436 | if cellOnShowQueue[identifier] == nil { 437 | cellOnShowQueue[identifier] = [] 438 | } 439 | cellOnShowQueue[identifier]!.append(cell) 440 | } 441 | } 442 | 443 | } 444 | 445 | extension CycleBannerView: UIScrollViewDelegate { 446 | 447 | public func scrollViewDidScroll(_ scrollView: UIScrollView) { 448 | showCellsByContentOffset(scrollView.contentOffset) 449 | showCellToReuseQueue(scrollView.contentOffset) 450 | } 451 | 452 | public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { 453 | setCurrentPageByContentOffset(scrollView.contentOffset) 454 | } 455 | 456 | public func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) { 457 | setCurrentPageByContentOffset(scrollView.contentOffset) 458 | } 459 | 460 | } 461 | 462 | -------------------------------------------------------------------------------- /Example/Example.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 80678A571FE7B42C00F4174D /* CycleBanner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 80678A561FE7B42400F4174D /* CycleBanner.framework */; }; 11 | 80678A581FE7B42C00F4174D /* CycleBanner.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 80678A561FE7B42400F4174D /* CycleBanner.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 12 | 80678A611FE7B5D000F4174D /* CustomCycleBannerViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80678A601FE7B5D000F4174D /* CustomCycleBannerViewCell.swift */; }; 13 | 80678A631FE7B5D800F4174D /* CustomCycleBannerViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 80678A621FE7B5D800F4174D /* CustomCycleBannerViewCell.xib */; }; 14 | 80B2183E1FE7B3150049A3F8 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80B2183D1FE7B3150049A3F8 /* AppDelegate.swift */; }; 15 | 80B218401FE7B3150049A3F8 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80B2183F1FE7B3150049A3F8 /* ViewController.swift */; }; 16 | 80B218431FE7B3150049A3F8 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 80B218411FE7B3150049A3F8 /* Main.storyboard */; }; 17 | 80B218451FE7B3150049A3F8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 80B218441FE7B3150049A3F8 /* Assets.xcassets */; }; 18 | 80B218481FE7B3150049A3F8 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 80B218461FE7B3150049A3F8 /* LaunchScreen.storyboard */; }; 19 | 80B218531FE7B3150049A3F8 /* ExampleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80B218521FE7B3150049A3F8 /* ExampleTests.swift */; }; 20 | 80B2185E1FE7B3150049A3F8 /* ExampleUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80B2185D1FE7B3150049A3F8 /* ExampleUITests.swift */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXContainerItemProxy section */ 24 | 80B2184F1FE7B3150049A3F8 /* PBXContainerItemProxy */ = { 25 | isa = PBXContainerItemProxy; 26 | containerPortal = 80B218321FE7B3150049A3F8 /* Project object */; 27 | proxyType = 1; 28 | remoteGlobalIDString = 80B218391FE7B3150049A3F8; 29 | remoteInfo = Example; 30 | }; 31 | 80B2185A1FE7B3150049A3F8 /* PBXContainerItemProxy */ = { 32 | isa = PBXContainerItemProxy; 33 | containerPortal = 80B218321FE7B3150049A3F8 /* Project object */; 34 | proxyType = 1; 35 | remoteGlobalIDString = 80B218391FE7B3150049A3F8; 36 | remoteInfo = Example; 37 | }; 38 | /* End PBXContainerItemProxy section */ 39 | 40 | /* Begin PBXCopyFilesBuildPhase section */ 41 | 80678A591FE7B42C00F4174D /* Embed Frameworks */ = { 42 | isa = PBXCopyFilesBuildPhase; 43 | buildActionMask = 2147483647; 44 | dstPath = ""; 45 | dstSubfolderSpec = 10; 46 | files = ( 47 | 80678A581FE7B42C00F4174D /* CycleBanner.framework in Embed Frameworks */, 48 | ); 49 | name = "Embed Frameworks"; 50 | runOnlyForDeploymentPostprocessing = 0; 51 | }; 52 | /* End PBXCopyFilesBuildPhase section */ 53 | 54 | /* Begin PBXFileReference section */ 55 | 80678A561FE7B42400F4174D /* CycleBanner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = CycleBanner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 56 | 80678A601FE7B5D000F4174D /* CustomCycleBannerViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomCycleBannerViewCell.swift; sourceTree = ""; }; 57 | 80678A621FE7B5D800F4174D /* CustomCycleBannerViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = CustomCycleBannerViewCell.xib; sourceTree = ""; }; 58 | 80B2183A1FE7B3150049A3F8 /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 59 | 80B2183D1FE7B3150049A3F8 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 60 | 80B2183F1FE7B3150049A3F8 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 61 | 80B218421FE7B3150049A3F8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 62 | 80B218441FE7B3150049A3F8 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 63 | 80B218471FE7B3150049A3F8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 64 | 80B218491FE7B3150049A3F8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 65 | 80B2184E1FE7B3150049A3F8 /* ExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ExampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 66 | 80B218521FE7B3150049A3F8 /* ExampleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleTests.swift; sourceTree = ""; }; 67 | 80B218541FE7B3150049A3F8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 68 | 80B218591FE7B3150049A3F8 /* ExampleUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ExampleUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 69 | 80B2185D1FE7B3150049A3F8 /* ExampleUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleUITests.swift; sourceTree = ""; }; 70 | 80B2185F1FE7B3150049A3F8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 71 | /* End PBXFileReference section */ 72 | 73 | /* Begin PBXFrameworksBuildPhase section */ 74 | 80B218371FE7B3150049A3F8 /* Frameworks */ = { 75 | isa = PBXFrameworksBuildPhase; 76 | buildActionMask = 2147483647; 77 | files = ( 78 | 80678A571FE7B42C00F4174D /* CycleBanner.framework in Frameworks */, 79 | ); 80 | runOnlyForDeploymentPostprocessing = 0; 81 | }; 82 | 80B2184B1FE7B3150049A3F8 /* Frameworks */ = { 83 | isa = PBXFrameworksBuildPhase; 84 | buildActionMask = 2147483647; 85 | files = ( 86 | ); 87 | runOnlyForDeploymentPostprocessing = 0; 88 | }; 89 | 80B218561FE7B3150049A3F8 /* Frameworks */ = { 90 | isa = PBXFrameworksBuildPhase; 91 | buildActionMask = 2147483647; 92 | files = ( 93 | ); 94 | runOnlyForDeploymentPostprocessing = 0; 95 | }; 96 | /* End PBXFrameworksBuildPhase section */ 97 | 98 | /* Begin PBXGroup section */ 99 | 80678A541FE7B42400F4174D /* Frameworks */ = { 100 | isa = PBXGroup; 101 | children = ( 102 | 80678A561FE7B42400F4174D /* CycleBanner.framework */, 103 | ); 104 | name = Frameworks; 105 | sourceTree = ""; 106 | }; 107 | 80B218311FE7B3150049A3F8 = { 108 | isa = PBXGroup; 109 | children = ( 110 | 80B2183C1FE7B3150049A3F8 /* Example */, 111 | 80B218511FE7B3150049A3F8 /* ExampleTests */, 112 | 80B2185C1FE7B3150049A3F8 /* ExampleUITests */, 113 | 80B2183B1FE7B3150049A3F8 /* Products */, 114 | 80678A541FE7B42400F4174D /* Frameworks */, 115 | ); 116 | sourceTree = ""; 117 | }; 118 | 80B2183B1FE7B3150049A3F8 /* Products */ = { 119 | isa = PBXGroup; 120 | children = ( 121 | 80B2183A1FE7B3150049A3F8 /* Example.app */, 122 | 80B2184E1FE7B3150049A3F8 /* ExampleTests.xctest */, 123 | 80B218591FE7B3150049A3F8 /* ExampleUITests.xctest */, 124 | ); 125 | name = Products; 126 | sourceTree = ""; 127 | }; 128 | 80B2183C1FE7B3150049A3F8 /* Example */ = { 129 | isa = PBXGroup; 130 | children = ( 131 | 80B2183D1FE7B3150049A3F8 /* AppDelegate.swift */, 132 | 80B2183F1FE7B3150049A3F8 /* ViewController.swift */, 133 | 80B218411FE7B3150049A3F8 /* Main.storyboard */, 134 | 80678A601FE7B5D000F4174D /* CustomCycleBannerViewCell.swift */, 135 | 80678A621FE7B5D800F4174D /* CustomCycleBannerViewCell.xib */, 136 | 80B218441FE7B3150049A3F8 /* Assets.xcassets */, 137 | 80B218461FE7B3150049A3F8 /* LaunchScreen.storyboard */, 138 | 80B218491FE7B3150049A3F8 /* Info.plist */, 139 | ); 140 | path = Example; 141 | sourceTree = ""; 142 | }; 143 | 80B218511FE7B3150049A3F8 /* ExampleTests */ = { 144 | isa = PBXGroup; 145 | children = ( 146 | 80B218521FE7B3150049A3F8 /* ExampleTests.swift */, 147 | 80B218541FE7B3150049A3F8 /* Info.plist */, 148 | ); 149 | path = ExampleTests; 150 | sourceTree = ""; 151 | }; 152 | 80B2185C1FE7B3150049A3F8 /* ExampleUITests */ = { 153 | isa = PBXGroup; 154 | children = ( 155 | 80B2185D1FE7B3150049A3F8 /* ExampleUITests.swift */, 156 | 80B2185F1FE7B3150049A3F8 /* Info.plist */, 157 | ); 158 | path = ExampleUITests; 159 | sourceTree = ""; 160 | }; 161 | /* End PBXGroup section */ 162 | 163 | /* Begin PBXNativeTarget section */ 164 | 80B218391FE7B3150049A3F8 /* Example */ = { 165 | isa = PBXNativeTarget; 166 | buildConfigurationList = 80B218621FE7B3150049A3F8 /* Build configuration list for PBXNativeTarget "Example" */; 167 | buildPhases = ( 168 | 80B218361FE7B3150049A3F8 /* Sources */, 169 | 80B218371FE7B3150049A3F8 /* Frameworks */, 170 | 80B218381FE7B3150049A3F8 /* Resources */, 171 | 80678A591FE7B42C00F4174D /* Embed Frameworks */, 172 | ); 173 | buildRules = ( 174 | ); 175 | dependencies = ( 176 | ); 177 | name = Example; 178 | productName = Example; 179 | productReference = 80B2183A1FE7B3150049A3F8 /* Example.app */; 180 | productType = "com.apple.product-type.application"; 181 | }; 182 | 80B2184D1FE7B3150049A3F8 /* ExampleTests */ = { 183 | isa = PBXNativeTarget; 184 | buildConfigurationList = 80B218651FE7B3150049A3F8 /* Build configuration list for PBXNativeTarget "ExampleTests" */; 185 | buildPhases = ( 186 | 80B2184A1FE7B3150049A3F8 /* Sources */, 187 | 80B2184B1FE7B3150049A3F8 /* Frameworks */, 188 | 80B2184C1FE7B3150049A3F8 /* Resources */, 189 | ); 190 | buildRules = ( 191 | ); 192 | dependencies = ( 193 | 80B218501FE7B3150049A3F8 /* PBXTargetDependency */, 194 | ); 195 | name = ExampleTests; 196 | productName = ExampleTests; 197 | productReference = 80B2184E1FE7B3150049A3F8 /* ExampleTests.xctest */; 198 | productType = "com.apple.product-type.bundle.unit-test"; 199 | }; 200 | 80B218581FE7B3150049A3F8 /* ExampleUITests */ = { 201 | isa = PBXNativeTarget; 202 | buildConfigurationList = 80B218681FE7B3150049A3F8 /* Build configuration list for PBXNativeTarget "ExampleUITests" */; 203 | buildPhases = ( 204 | 80B218551FE7B3150049A3F8 /* Sources */, 205 | 80B218561FE7B3150049A3F8 /* Frameworks */, 206 | 80B218571FE7B3150049A3F8 /* Resources */, 207 | ); 208 | buildRules = ( 209 | ); 210 | dependencies = ( 211 | 80B2185B1FE7B3150049A3F8 /* PBXTargetDependency */, 212 | ); 213 | name = ExampleUITests; 214 | productName = ExampleUITests; 215 | productReference = 80B218591FE7B3150049A3F8 /* ExampleUITests.xctest */; 216 | productType = "com.apple.product-type.bundle.ui-testing"; 217 | }; 218 | /* End PBXNativeTarget section */ 219 | 220 | /* Begin PBXProject section */ 221 | 80B218321FE7B3150049A3F8 /* Project object */ = { 222 | isa = PBXProject; 223 | attributes = { 224 | LastSwiftUpdateCheck = 0920; 225 | LastUpgradeCheck = 0920; 226 | ORGANIZATIONNAME = Jiar; 227 | TargetAttributes = { 228 | 80B218391FE7B3150049A3F8 = { 229 | CreatedOnToolsVersion = 9.2; 230 | ProvisioningStyle = Automatic; 231 | }; 232 | 80B2184D1FE7B3150049A3F8 = { 233 | CreatedOnToolsVersion = 9.2; 234 | ProvisioningStyle = Automatic; 235 | TestTargetID = 80B218391FE7B3150049A3F8; 236 | }; 237 | 80B218581FE7B3150049A3F8 = { 238 | CreatedOnToolsVersion = 9.2; 239 | ProvisioningStyle = Automatic; 240 | TestTargetID = 80B218391FE7B3150049A3F8; 241 | }; 242 | }; 243 | }; 244 | buildConfigurationList = 80B218351FE7B3150049A3F8 /* Build configuration list for PBXProject "Example" */; 245 | compatibilityVersion = "Xcode 8.0"; 246 | developmentRegion = en; 247 | hasScannedForEncodings = 0; 248 | knownRegions = ( 249 | en, 250 | Base, 251 | ); 252 | mainGroup = 80B218311FE7B3150049A3F8; 253 | productRefGroup = 80B2183B1FE7B3150049A3F8 /* Products */; 254 | projectDirPath = ""; 255 | projectRoot = ""; 256 | targets = ( 257 | 80B218391FE7B3150049A3F8 /* Example */, 258 | 80B2184D1FE7B3150049A3F8 /* ExampleTests */, 259 | 80B218581FE7B3150049A3F8 /* ExampleUITests */, 260 | ); 261 | }; 262 | /* End PBXProject section */ 263 | 264 | /* Begin PBXResourcesBuildPhase section */ 265 | 80B218381FE7B3150049A3F8 /* Resources */ = { 266 | isa = PBXResourcesBuildPhase; 267 | buildActionMask = 2147483647; 268 | files = ( 269 | 80B218481FE7B3150049A3F8 /* LaunchScreen.storyboard in Resources */, 270 | 80B218451FE7B3150049A3F8 /* Assets.xcassets in Resources */, 271 | 80678A631FE7B5D800F4174D /* CustomCycleBannerViewCell.xib in Resources */, 272 | 80B218431FE7B3150049A3F8 /* Main.storyboard in Resources */, 273 | ); 274 | runOnlyForDeploymentPostprocessing = 0; 275 | }; 276 | 80B2184C1FE7B3150049A3F8 /* Resources */ = { 277 | isa = PBXResourcesBuildPhase; 278 | buildActionMask = 2147483647; 279 | files = ( 280 | ); 281 | runOnlyForDeploymentPostprocessing = 0; 282 | }; 283 | 80B218571FE7B3150049A3F8 /* Resources */ = { 284 | isa = PBXResourcesBuildPhase; 285 | buildActionMask = 2147483647; 286 | files = ( 287 | ); 288 | runOnlyForDeploymentPostprocessing = 0; 289 | }; 290 | /* End PBXResourcesBuildPhase section */ 291 | 292 | /* Begin PBXSourcesBuildPhase section */ 293 | 80B218361FE7B3150049A3F8 /* Sources */ = { 294 | isa = PBXSourcesBuildPhase; 295 | buildActionMask = 2147483647; 296 | files = ( 297 | 80678A611FE7B5D000F4174D /* CustomCycleBannerViewCell.swift in Sources */, 298 | 80B218401FE7B3150049A3F8 /* ViewController.swift in Sources */, 299 | 80B2183E1FE7B3150049A3F8 /* AppDelegate.swift in Sources */, 300 | ); 301 | runOnlyForDeploymentPostprocessing = 0; 302 | }; 303 | 80B2184A1FE7B3150049A3F8 /* Sources */ = { 304 | isa = PBXSourcesBuildPhase; 305 | buildActionMask = 2147483647; 306 | files = ( 307 | 80B218531FE7B3150049A3F8 /* ExampleTests.swift in Sources */, 308 | ); 309 | runOnlyForDeploymentPostprocessing = 0; 310 | }; 311 | 80B218551FE7B3150049A3F8 /* Sources */ = { 312 | isa = PBXSourcesBuildPhase; 313 | buildActionMask = 2147483647; 314 | files = ( 315 | 80B2185E1FE7B3150049A3F8 /* ExampleUITests.swift in Sources */, 316 | ); 317 | runOnlyForDeploymentPostprocessing = 0; 318 | }; 319 | /* End PBXSourcesBuildPhase section */ 320 | 321 | /* Begin PBXTargetDependency section */ 322 | 80B218501FE7B3150049A3F8 /* PBXTargetDependency */ = { 323 | isa = PBXTargetDependency; 324 | target = 80B218391FE7B3150049A3F8 /* Example */; 325 | targetProxy = 80B2184F1FE7B3150049A3F8 /* PBXContainerItemProxy */; 326 | }; 327 | 80B2185B1FE7B3150049A3F8 /* PBXTargetDependency */ = { 328 | isa = PBXTargetDependency; 329 | target = 80B218391FE7B3150049A3F8 /* Example */; 330 | targetProxy = 80B2185A1FE7B3150049A3F8 /* PBXContainerItemProxy */; 331 | }; 332 | /* End PBXTargetDependency section */ 333 | 334 | /* Begin PBXVariantGroup section */ 335 | 80B218411FE7B3150049A3F8 /* Main.storyboard */ = { 336 | isa = PBXVariantGroup; 337 | children = ( 338 | 80B218421FE7B3150049A3F8 /* Base */, 339 | ); 340 | name = Main.storyboard; 341 | sourceTree = ""; 342 | }; 343 | 80B218461FE7B3150049A3F8 /* LaunchScreen.storyboard */ = { 344 | isa = PBXVariantGroup; 345 | children = ( 346 | 80B218471FE7B3150049A3F8 /* Base */, 347 | ); 348 | name = LaunchScreen.storyboard; 349 | sourceTree = ""; 350 | }; 351 | /* End PBXVariantGroup section */ 352 | 353 | /* Begin XCBuildConfiguration section */ 354 | 80B218601FE7B3150049A3F8 /* Debug */ = { 355 | isa = XCBuildConfiguration; 356 | buildSettings = { 357 | ALWAYS_SEARCH_USER_PATHS = NO; 358 | CLANG_ANALYZER_NONNULL = YES; 359 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 360 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 361 | CLANG_CXX_LIBRARY = "libc++"; 362 | CLANG_ENABLE_MODULES = YES; 363 | CLANG_ENABLE_OBJC_ARC = YES; 364 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 365 | CLANG_WARN_BOOL_CONVERSION = YES; 366 | CLANG_WARN_COMMA = YES; 367 | CLANG_WARN_CONSTANT_CONVERSION = YES; 368 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 369 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 370 | CLANG_WARN_EMPTY_BODY = YES; 371 | CLANG_WARN_ENUM_CONVERSION = YES; 372 | CLANG_WARN_INFINITE_RECURSION = YES; 373 | CLANG_WARN_INT_CONVERSION = YES; 374 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 375 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 376 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 377 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 378 | CLANG_WARN_STRICT_PROTOTYPES = YES; 379 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 380 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 381 | CLANG_WARN_UNREACHABLE_CODE = YES; 382 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 383 | CODE_SIGN_IDENTITY = "iPhone Developer"; 384 | COPY_PHASE_STRIP = NO; 385 | DEBUG_INFORMATION_FORMAT = dwarf; 386 | ENABLE_STRICT_OBJC_MSGSEND = YES; 387 | ENABLE_TESTABILITY = YES; 388 | GCC_C_LANGUAGE_STANDARD = gnu11; 389 | GCC_DYNAMIC_NO_PIC = NO; 390 | GCC_NO_COMMON_BLOCKS = YES; 391 | GCC_OPTIMIZATION_LEVEL = 0; 392 | GCC_PREPROCESSOR_DEFINITIONS = ( 393 | "DEBUG=1", 394 | "$(inherited)", 395 | ); 396 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 397 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 398 | GCC_WARN_UNDECLARED_SELECTOR = YES; 399 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 400 | GCC_WARN_UNUSED_FUNCTION = YES; 401 | GCC_WARN_UNUSED_VARIABLE = YES; 402 | IPHONEOS_DEPLOYMENT_TARGET = 11.2; 403 | MTL_ENABLE_DEBUG_INFO = YES; 404 | ONLY_ACTIVE_ARCH = YES; 405 | SDKROOT = iphoneos; 406 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 407 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 408 | }; 409 | name = Debug; 410 | }; 411 | 80B218611FE7B3150049A3F8 /* Release */ = { 412 | isa = XCBuildConfiguration; 413 | buildSettings = { 414 | ALWAYS_SEARCH_USER_PATHS = NO; 415 | CLANG_ANALYZER_NONNULL = YES; 416 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 417 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 418 | CLANG_CXX_LIBRARY = "libc++"; 419 | CLANG_ENABLE_MODULES = YES; 420 | CLANG_ENABLE_OBJC_ARC = YES; 421 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 422 | CLANG_WARN_BOOL_CONVERSION = YES; 423 | CLANG_WARN_COMMA = YES; 424 | CLANG_WARN_CONSTANT_CONVERSION = YES; 425 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 426 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 427 | CLANG_WARN_EMPTY_BODY = YES; 428 | CLANG_WARN_ENUM_CONVERSION = YES; 429 | CLANG_WARN_INFINITE_RECURSION = YES; 430 | CLANG_WARN_INT_CONVERSION = YES; 431 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 432 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 433 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 434 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 435 | CLANG_WARN_STRICT_PROTOTYPES = YES; 436 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 437 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 438 | CLANG_WARN_UNREACHABLE_CODE = YES; 439 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 440 | CODE_SIGN_IDENTITY = "iPhone Developer"; 441 | COPY_PHASE_STRIP = NO; 442 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 443 | ENABLE_NS_ASSERTIONS = NO; 444 | ENABLE_STRICT_OBJC_MSGSEND = YES; 445 | GCC_C_LANGUAGE_STANDARD = gnu11; 446 | GCC_NO_COMMON_BLOCKS = YES; 447 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 448 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 449 | GCC_WARN_UNDECLARED_SELECTOR = YES; 450 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 451 | GCC_WARN_UNUSED_FUNCTION = YES; 452 | GCC_WARN_UNUSED_VARIABLE = YES; 453 | IPHONEOS_DEPLOYMENT_TARGET = 11.2; 454 | MTL_ENABLE_DEBUG_INFO = NO; 455 | SDKROOT = iphoneos; 456 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 457 | VALIDATE_PRODUCT = YES; 458 | }; 459 | name = Release; 460 | }; 461 | 80B218631FE7B3150049A3F8 /* Debug */ = { 462 | isa = XCBuildConfiguration; 463 | buildSettings = { 464 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 465 | CODE_SIGN_STYLE = Automatic; 466 | DEVELOPMENT_TEAM = D4MTBNMTU5; 467 | INFOPLIST_FILE = Example/Info.plist; 468 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 469 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 470 | PRODUCT_BUNDLE_IDENTIFIER = Jiar.Example; 471 | PRODUCT_NAME = "$(TARGET_NAME)"; 472 | SWIFT_VERSION = 4.0; 473 | TARGETED_DEVICE_FAMILY = "1,2"; 474 | }; 475 | name = Debug; 476 | }; 477 | 80B218641FE7B3150049A3F8 /* Release */ = { 478 | isa = XCBuildConfiguration; 479 | buildSettings = { 480 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 481 | CODE_SIGN_STYLE = Automatic; 482 | DEVELOPMENT_TEAM = D4MTBNMTU5; 483 | INFOPLIST_FILE = Example/Info.plist; 484 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 485 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 486 | PRODUCT_BUNDLE_IDENTIFIER = Jiar.Example; 487 | PRODUCT_NAME = "$(TARGET_NAME)"; 488 | SWIFT_VERSION = 4.0; 489 | TARGETED_DEVICE_FAMILY = "1,2"; 490 | }; 491 | name = Release; 492 | }; 493 | 80B218661FE7B3150049A3F8 /* Debug */ = { 494 | isa = XCBuildConfiguration; 495 | buildSettings = { 496 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 497 | BUNDLE_LOADER = "$(TEST_HOST)"; 498 | CODE_SIGN_STYLE = Automatic; 499 | INFOPLIST_FILE = ExampleTests/Info.plist; 500 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 501 | PRODUCT_BUNDLE_IDENTIFIER = Jiar.ExampleTests; 502 | PRODUCT_NAME = "$(TARGET_NAME)"; 503 | SWIFT_VERSION = 4.0; 504 | TARGETED_DEVICE_FAMILY = "1,2"; 505 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Example.app/Example"; 506 | }; 507 | name = Debug; 508 | }; 509 | 80B218671FE7B3150049A3F8 /* Release */ = { 510 | isa = XCBuildConfiguration; 511 | buildSettings = { 512 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 513 | BUNDLE_LOADER = "$(TEST_HOST)"; 514 | CODE_SIGN_STYLE = Automatic; 515 | INFOPLIST_FILE = ExampleTests/Info.plist; 516 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 517 | PRODUCT_BUNDLE_IDENTIFIER = Jiar.ExampleTests; 518 | PRODUCT_NAME = "$(TARGET_NAME)"; 519 | SWIFT_VERSION = 4.0; 520 | TARGETED_DEVICE_FAMILY = "1,2"; 521 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Example.app/Example"; 522 | }; 523 | name = Release; 524 | }; 525 | 80B218691FE7B3150049A3F8 /* Debug */ = { 526 | isa = XCBuildConfiguration; 527 | buildSettings = { 528 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 529 | CODE_SIGN_STYLE = Automatic; 530 | INFOPLIST_FILE = ExampleUITests/Info.plist; 531 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 532 | PRODUCT_BUNDLE_IDENTIFIER = Jiar.ExampleUITests; 533 | PRODUCT_NAME = "$(TARGET_NAME)"; 534 | SWIFT_VERSION = 4.0; 535 | TARGETED_DEVICE_FAMILY = "1,2"; 536 | TEST_TARGET_NAME = Example; 537 | }; 538 | name = Debug; 539 | }; 540 | 80B2186A1FE7B3150049A3F8 /* Release */ = { 541 | isa = XCBuildConfiguration; 542 | buildSettings = { 543 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 544 | CODE_SIGN_STYLE = Automatic; 545 | INFOPLIST_FILE = ExampleUITests/Info.plist; 546 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 547 | PRODUCT_BUNDLE_IDENTIFIER = Jiar.ExampleUITests; 548 | PRODUCT_NAME = "$(TARGET_NAME)"; 549 | SWIFT_VERSION = 4.0; 550 | TARGETED_DEVICE_FAMILY = "1,2"; 551 | TEST_TARGET_NAME = Example; 552 | }; 553 | name = Release; 554 | }; 555 | /* End XCBuildConfiguration section */ 556 | 557 | /* Begin XCConfigurationList section */ 558 | 80B218351FE7B3150049A3F8 /* Build configuration list for PBXProject "Example" */ = { 559 | isa = XCConfigurationList; 560 | buildConfigurations = ( 561 | 80B218601FE7B3150049A3F8 /* Debug */, 562 | 80B218611FE7B3150049A3F8 /* Release */, 563 | ); 564 | defaultConfigurationIsVisible = 0; 565 | defaultConfigurationName = Release; 566 | }; 567 | 80B218621FE7B3150049A3F8 /* Build configuration list for PBXNativeTarget "Example" */ = { 568 | isa = XCConfigurationList; 569 | buildConfigurations = ( 570 | 80B218631FE7B3150049A3F8 /* Debug */, 571 | 80B218641FE7B3150049A3F8 /* Release */, 572 | ); 573 | defaultConfigurationIsVisible = 0; 574 | defaultConfigurationName = Release; 575 | }; 576 | 80B218651FE7B3150049A3F8 /* Build configuration list for PBXNativeTarget "ExampleTests" */ = { 577 | isa = XCConfigurationList; 578 | buildConfigurations = ( 579 | 80B218661FE7B3150049A3F8 /* Debug */, 580 | 80B218671FE7B3150049A3F8 /* Release */, 581 | ); 582 | defaultConfigurationIsVisible = 0; 583 | defaultConfigurationName = Release; 584 | }; 585 | 80B218681FE7B3150049A3F8 /* Build configuration list for PBXNativeTarget "ExampleUITests" */ = { 586 | isa = XCConfigurationList; 587 | buildConfigurations = ( 588 | 80B218691FE7B3150049A3F8 /* Debug */, 589 | 80B2186A1FE7B3150049A3F8 /* Release */, 590 | ); 591 | defaultConfigurationIsVisible = 0; 592 | defaultConfigurationName = Release; 593 | }; 594 | /* End XCConfigurationList section */ 595 | }; 596 | rootObject = 80B218321FE7B3150049A3F8 /* Project object */; 597 | } 598 | --------------------------------------------------------------------------------