DroidsOnRoids / SwiftCarousel

Lightweight, written natively in Swift, circular UIScrollView.
http://www.thedroidsonroids.com/blog/ios/circular-scroll-view-swiftcarousel/
MIT License
144 stars 43 forks source link

Some of the carousel cells don't have their layer properties corrects #22

Closed frranck closed 8 years ago

frranck commented 8 years ago

Hi; I noticed some of the carousel cells don't have their cornerRadius set properly; I can see them with proper corners once; but when you keep scrolling I'm seeing the same cells with no cornerRadius. Could that be an issue with the copyView function ?


    /**
     Method to copy UIView using archivizing.

     - returns: Copied UIView (different memory address than current)
     */
    public func copyView() throws -> UIView {
        prepareConstraintsForArchiving()
        guard let view = NSKeyedUnarchiver.unarchiveObjectWithData(NSKeyedArchiver.archivedDataWithRootObject(self)) as? UIView else { throw ArchiveCopyingError.View }
        return view
    }
sunshinejr commented 8 years ago

Thanks for the issue!

We improved the copyView() method in version 0.5, could you try to check if it happens on this version as well?

frranck commented 8 years ago

@sunshinejr I'm using the 0.5

sunshinejr commented 8 years ago

Oh right, the copyView() method can't really copy CALayer. You can use our itemsFactory() method, we introduced it after #11 in version 0.5. Here is an example. Sorry for the inconvenience!

frranck commented 8 years ago

@sunshinejr I'm not using it; but I suspect the problem is coming because the library using it line 104 .

sunshinejr commented 8 years ago

@frranck yes, the copyView() method does the copy of view because the views are passed it in the array. When you pass it in the closure (and make a new view in it) using itemsFactory(), the views can be created from the recipe rather than copy it, which allows you to copy not only the view, but also models & objects (like view models or CALayer).

frranck commented 8 years ago

@sunshinejr Thanks for the input