Half circle carousel menu

45 views Asked by At

Hi I tried to create a half circle carousel but I can't do with iCarousel with inverted wheel type.

Please check image

My code is :

import UIKit

class ViewController: UIViewController, kCarouselDataSource, kCarouselDelegate {
    func numberOfItems(in carousel: kCarousel) -> Int {
        return images.count
    }
    

    var images : NSMutableArray = NSMutableArray()
    var selectedIndex : Int!
    @IBOutlet var vwCarousel: kCarousel!
    
    lazy var cardSize:CGRect = {
        let width  = self.vwCarousel.frame.width
        let height = self.vwCarousel.frame.height
        let frame = CGRect(x: 0, y: 0, width: width, height: height)
        return frame
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        images = NSMutableArray(array: ["casino","HotGames","Sports","InstantGames","Bonus"])
        vwCarousel.type = .carouselTypeInvertedWheel
        //vwCarousel.perspective = 0
        vwCarousel.contentMode = .scaleAspectFill
        vwCarousel.isPagingEnabled = true
        
        
       // vwCarousel.decelerationRate = 1.0
        vwCarousel .reloadData()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
 
    //MARK: kCarousel delegate methods
    
    func numberOfItemsInCarousel(carousel: kCarousel) -> Int
    {
        return images.count
    }
    
    func carousel(_ carousel: kCarousel, viewForItemAt index: Int, reusing view: UIView?) -> UIView
    {
        
        var toDoCardListView: CellView?
       
                if (view == nil)
                {
                    //itemView = UIImageView(frame:CGRect(x:0, y:0, width:125, height:125))
        
                    if index == vwCarousel.currentItemIndex
                    {
                        toDoCardListView = CellView(frame: CGRect(x: 0, y: 0, width: 140, height: 140))
                        
                    }
                    else
                    {
                        
                            toDoCardListView = CellView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
                        
                    }
                }
                else
                {
                    toDoCardListView = view as? CellView;
                }
        
        toDoCardListView?.frontImage.image =  UIImage(named: "\(images.object(at: index))")
         
        if index == vwCarousel.currentItemIndex
        {
            toDoCardListView?.backImage.image =  UIImage(named: "Selected")
        }
        else
        {
            toDoCardListView?.backImage.image =  UIImage(named: "Normal")
        }
        
        return toDoCardListView!
        
  
    }
    
    func carousel(_ carousel: kCarousel, didSelectItemAt index: Int) {
        selectedIndex = index
        print("INDEX:\(String(describing: selectedIndex))")
    }
    
   
    
    func carouselCurrentItemIndexDidChange(_ carousel: kCarousel) {
        
        var currectIndex = vwCarousel.currentItemIndex;
        
        
        if vwCarousel.currentItemIndex == -1
        {
            currectIndex = 0
        }
        vwCarousel .reloadData()
        print("Current Index:\(String(describing: currectIndex))")
        
    }
    
    
    
    
    
  
    
    func carousel(_ carousel: kCarousel, valueFor option: kCarouselOption, withDefault value: CGFloat) -> CGFloat {
        switch (option) {
        case .carouselOptionSpacing: return 1.0 // 2 points spacing
            default: return value
        }
    }
   
    
}

I want to create exact result as per showing screenshot. but my problem is i cant customize size of the cell and space correctly. please help me to get clear solution please.

0

There are 0 answers