Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom layer masks conflict with internal MarqueeLabel masking #214

Open
snc001 opened this issue May 7, 2018 · 4 comments
Open

Custom layer masks conflict with internal MarqueeLabel masking #214

snc001 opened this issue May 7, 2018 · 4 comments

Comments

@snc001
Copy link

snc001 commented May 7, 2018

Usage Details

  • Language: Swift
  • Platform: iPhone

Steps to Reproduce the Problem

  1. Clone the latest MarqueeLabel from Zip
  2. Import MarqueeLabel.swift manually into project
  3. Import QuartzCore.framework in build.phase link binary
  4. Used MarqueeLabel where is needed
  5. Clean project
  6. Run project on simulator - iOS 11.3; iPhone 8 Plus
    5 error on line 1153 - Could not cast value of type 'CAShapeLayer' (0x111186cc0) to 'CAGradientLayer' (0x111187260) from MarqueeLabel.swift

Is there something that I have missed or have done wrong??

Any help is much appreciated :)

@cbpowell
Copy link
Owner

cbpowell commented May 8, 2018

That's pretty weird, because line 1153 is where MarqueeLabel just returns the mask of the base view layer, and the only place the mask layer is set is at line 1029…where it is set as a CAGradientLayer.

Does your project code mask the MarqueeLabel in any way, by setting the aLabel.layer.mask property?

@snc001
Copy link
Author

snc001 commented May 8, 2018

Spot on! Yes I do for custom border rounding.

let nameLabelEdge = CAShapeLayer() nameLabelEdge.bounds = nameLabel.frame nameLabelEdge.position = nameLabel.center nameLabelEdge.path = UIBezierPath(roundedRect: nameLabel.bounds, byRoundingCorners: [.topLeft, .topRight], cornerRadii: CGSize(width: 9, height: 9)).cgPath nameLabel.layer.mask = nameLabelEdge

That is exactly how i have it at the moment

@snc001 snc001 closed this as completed May 8, 2018
@snc001 snc001 reopened this May 8, 2018
@cbpowell
Copy link
Owner

cbpowell commented May 8, 2018

So yep that's the reason, your CAShapeLayer is replacing the CAGradientLayer that MarqueeLabel assigns to itself to handle the fading at the left and right edges.

There's probably a way for MarqueeLabel to mask itself without using the top layer mask so that it doesn't conflict, but I'll have to look into it. I think the quick and easy way for you to fix it right now would be to just put your MarqueeLabel instance inside a wrapper UIView and then mask that wrapper view.

@snc001
Copy link
Author

snc001 commented May 10, 2018

Yea that's exactly what i did as a work around =)

@cbpowell cbpowell changed the title Could not cast value of type 'CAShapeLayer' to 'CAGradientLayer' Custom layer masks conflict with internal MarqueeLabel masking Jun 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants