Giter VIP home page Giter VIP logo

aacarousel's Introduction

AACarousel

Carthage Compatible

Easy to create image slider in Swift

Feature

  • pure swift 4.2 code
  • class is custom UIView , not UIPageViewController
  • you can download image use iOS native SDK or other 3rd SDK
  • require iOS 8 or later

Style One

Style Two

Installation

CocoaPods

AACarousel is available through CocoaPods.

Simply add AACarousel to your Podfile.

pod 'AACarousel'

Enter command instruction into your terminal.

pod install

Carthage

AACarousel is available through Carthage.

Simply add AACarousel to your Cartfile.

github "Alan881/AACarousel"

Enter command instruction into your terminal.

carthage update --platform iOS

Usage

You must create UIView and it use custom class in the storyboard after install AACarousel.

Then you must also create a IBOutlet in your UIViewController Class with AACarouselDelegate.

The following sample code for your reference.

    var titleArray = [String]()
    
    override func viewDidLoad() {
        super.viewDidLoad()
     
        let pathArray = ["http://www.gettyimages.ca/gi-resources/images/Embed/new/embed2.jpg",
                        "https://ak.picdn.net/assets/cms/97e1dd3f8a3ecb81356fe754a1a113f31b6dbfd4-stock-photo-photo-of-a-common-kingfisher-alcedo-atthis-adult-male-perched-on-a-lichen-covered-branch-107647640.jpg",
                        "https://imgct2.aeplcdn.com/img/800x600/car-data/big/honda-amaze-image-12749.png",
                        "http://www.conversion-uplift.co.uk/wp-content/uploads/2016/09/Lamborghini-Huracan-Image-672x372.jpg",
                        "very-large-flamingo"]
        titleArray = ["picture 1","picture 2","picture 3","picture 4","picture 5"]
        carouselView.delegate = self
        carouselView.setCarouselData(paths: pathArray,  describedTitle: titleArray, isAutoScroll: true, timer: 5.0, defaultImage: "defaultImage")
        //optional methods
        carouselView.setCarouselOpaque(layer: false, describedTitle: false, pageIndicator: false)
        carouselView.setCarouselLayout(displayStyle: 0, pageIndicatorPositon: 5, pageIndicatorColor: nil, describedTitleColor: nil, layerColor: nil)
    }
    //require method
    func downloadImages(_ url: String, _ index: Int) {
        
        //here is download images area
         let imageView = UIImageView()
        imageView.kf.setImage(with: URL(string: url)!, placeholder: UIImage.init(named: "defaultImage"), options: [.transition(.fade(0))], progressBlock: nil, completionHandler: { (downloadImage, error, cacheType, url) in
            self.carouselView.images[index] = downloadImage!
        })
    }
    //optional method (interaction for touch image)
    func didSelectCarouselView(_ view: AACarousel ,_ index: Int) {
        
        let alert = UIAlertView.init(title:"Alert" , message: titleArray[index], delegate: self, cancelButtonTitle: "OK")
        alert.show()
        
        //startAutoScroll()
        //stopAutoScroll()
    }
    
    //optional method (show first image faster during downloading of all images)
    func callBackFirstDisplayView(_ imageView: UIImageView, _ url: [String], _ index: Int) {
        
        imageView.kf.setImage(with: URL(string: url[index]), placeholder: UIImage.init(named: "defaultImage"), options: [.transition(.fade(1))], progressBlock: nil, completionHandler: nil)
        
    }
    
    func startAutoScroll() {
       //optional method
       carouselView.startScrollImageView()
        
    }
    
    func stopAutoScroll() {
        //optional method
        carouselView.stopScrollImageView()
    }

License

AACarousel is available under the MIT license. See the LICENSE file for more info.

aacarousel's People

Contributors

alan881 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

aacarousel's Issues

Add imageView to first index

I am able to add imageView to view but after scrolling left or right background view shows first then image. I want only image.

the first image never show up even though the download image is already finished

so the first image in the array will never show up, except if I change to the page control 2 (index 1), and goes back to the page control 1 (index 0) then the image is eventually show up

here is the .gif file of my problem:
http://g.recordit.co/EdK3BzgCCj.gif

even if I use the image in the asset, the problem is still there

the pod I use

# Uncomment the next line to define a global platform for your project
 platform :ios, '9.0'

target 'AATheCorousel' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for AATheCorousel
pod 'AACarousel'
pod 'Kingfisher', '~> 4.0'

end

and here is the code I use


import UIKit
import AACarousel
import Kingfisher

class ViewController: UIViewController, AACarouselDelegate {
   
    
    
    @IBOutlet var corouselView: AACarousel!
    

    var titleArray = [String]()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let pathArray = ["http://www.conversion-uplift.co.uk/wp-content/uploads/2016/09/Lamborghini-Huracan-Image-672x372.jpg",
                         "https://ak.picdn.net/assets/cms/97e1dd3f8a3ecb81356fe754a1a113f31b6dbfd4-stock-photo-photo-of-a-common-kingfisher-alcedo-atthis-adult-male-perched-on-a-lichen-covered-branch-107647640.jpg",
                         "https://imgct2.aeplcdn.com/img/800x600/car-data/big/honda-amaze-image-12749.png",
                         "http://www.conversion-uplift.co.uk/wp-content/uploads/2016/09/Lamborghini-Huracan-Image-672x372.jpg",
                         "https://imgct2.aeplcdn.com/img/800x600/car-data/big/honda-amaze-image-12749.png"]
        titleArray = ["picture 1","picture 2","picture 3","picture 4","picture 5"]
        corouselView.delegate = self
        corouselView.setCarouselData(paths: pathArray,  describedTitle: titleArray, isAutoScroll: false, timer: 5.0, defaultImage: "defaultImage")
        
        //optional methods
        corouselView.setCarouselOpaque(layer: false, describedTitle: false, pageIndicator: false)
        corouselView.setCarouselLayout(displayStyle: 0, pageIndicatorPositon: 2, pageIndicatorColor: nil, describedTitleColor: nil, layerColor: nil)
    }
    
    func didSelectCarouselView(_ view: AACarousel, _ index: Int) {
        
    }
    
    func callBackFirstDisplayView(_ imageView: UIImageView, _ url: [String], _ index: Int) {
        
    }
    
    func downloadImages(_ url: String, _ index: Int) {
        //here is download images area
        
        
        let imageView = UIImageView()
        imageView.kf.setImage(with: URL(string: url)!, placeholder: nil, options: nil, progressBlock: nil) { (downloadImage, error, cache, url) in
            self.corouselView.images[index] = downloadImage!
        }
        
        
        
        
    }

   

}

undeclared type AACarousel

Hi Recently I was installing pod it. and am getting same error above it (undecleared AACarousel). i don't know how to install carthage and use it. please help me

Carthage support?

Hi,

Very nice.

It have Carthage support?

Can you add it not?

Thanks.

Bug when no banner is on carousel

Bug when no banner is on carousel

If you don't put any banner on carousel, but show it, when tap the project crash.

Line that crash:

//MARK:- UITapGestureRecognizer
    @objc fileprivate func didSelectImageView() {
        
        if let delegate = delegate {
            if let method = delegate.didSelectCarouselView {
                method(self, currentIndex)    // <--- crash
                return
            }
        }
}

I think that it is simple, can you fix it?
Thanks.

Value of type 'UIImageView' has no member 'kf'

I am getting this error while writing this line

imageView.kf.setImage(with: URL(string: url[index]), placeholder: UIImage.init(named: "defaultImage"), options: [.transition(.fade(1))], progressBlock: nil, completionHandler: nil)

Bug when rotate device two times

Hi,

When i rotate my device two times (from portrait to landscape, wait 5 seconds, from landscape to portrait), i got a crash:

image

Can you help me?

Local images + option values

Please add in readme how to handle local images?

Also, for various options, like position of indicator, and colors, please put in infographic to clearly show how to set options?

Does the library support iPhone applications?

I like the library and it is what I need for my app.
but can I use it for my iPhone application?
because from the pictures, it looks like it is for big size screens like the iPad

sorry for my newb question

Two images on the same screen

Hi,

How are you?

How can i show two images on the same screen? I want show two images on tablet, instead of show only one with big height. Like in this screenshot:

screenshot_20180713-151933

The following binaries use incompatible versions of Swift:

Hey, there I am using Xcode version 9.4.1. Whenever I try to build I get this error.
error: The following binaries use incompatible versions of Swift:
/Users/yugstart/Library/Developer/Xcode/DerivedData/Groupool-amsflkbggzuopgbegwbuvdefhrys/Build/Products/Debug-iphonesimulator/Groupool.app/Groupool
/Volumes/Yugstart-Work/Xcode/groupool_ios_dev/Groupool/AACarousel.framework/AACarousel

Please let me know the solution.

Banners loaded but not showed

Hi,

I put a log on "downloadImages" and see that all 3 banner is loaded, but it still on first banner with blank background without image. The image only show when i change page and back.

How can i solve it? Banner need be showed on the current page when it is loaded without need change page.

Thanks.

First Slider Image not visible first time

First of all, I want to give you many many thanks for this awesome, sweet plugin. But the problem is in first load the first image of the slider is not visible, it's showing a blank white area. I check the same issue, but that doesn't work for me. Can you help on this matter? Advance thanks for your help. I just use this simple piece of code.

`
let pathArray = ["slider1",
"slider2",
"slider3"
]
titleArray = ["picture 1","picture 2","picture 3"]

    slider.delegate = self as? AACarouselDelegate
    
    slider.setCarouselData(paths: pathArray,  describedTitle: titleArray, isAutoScroll: true, timer: 10.0, defaultImage: "slider1")
    //optional methods
    slider.setCarouselOpaque(layer: true, describedTitle: false, pageIndicator: false)
    slider.setCarouselLayout(displayStyle: 0, pageIndicatorPositon: 5, pageIndicatorColor: nil, describedTitleColor: nil, layerColor: nil)`

or one more question can I set the default select number 2 image of the slider?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.