rechsteiner / Parchment

A paging view with a highly customizable menu ✨
MIT License
3.39k stars 419 forks source link

how to make collectionview rounded and add shadow to collectionview #682

Closed NikhilGangurde closed 1 year ago

NikhilGangurde commented 1 year ago
Screenshot 2023-04-19 at 9 33 02 PM

how can i make this view

here is what I tried and not working:

class RoundedPagingCell: PagingTitleCell {

   open override func setPagingItem(_ pagingItem: PagingItem, selected: Bool, options: PagingOptions) {
    super.setPagingItem(pagingItem, selected: selected, options: options)
       guard let item = pagingItem as? PagingIndexItem else { return }

    // Apply shadow to content view

    if item.index == 0 {
        contentView.dropShadow(offsetX: 0, offsetY: 0, color: .lightGray, opacity: 0.5, radius: 10)
    } else if item.index == 2 {
        contentView.dropShadow(offsetX: 0, offsetY: 0, color: .lightGray, opacity: 0.5, radius: 10)
    }

  }

}
rechsteiner commented 1 year ago

Hi @NikhilGangurde! It's a bit hard to say why that’s not working based on your example. In general, it should be possible to apply the corner radius inside the cell, based on the index of the item. Another option would be to apply the corner radius on the pagingController.collectionView itself. You can provide your own PagingView subclass where you can completely customize the layout and size of the collection view as well.