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

ContentMode not working #517

Closed
EternalBlack opened this issue Jan 9, 2019 · 5 comments
Closed

ContentMode not working #517

EternalBlack opened this issue Jan 9, 2019 · 5 comments
Assignees
Milestone

Comments

@EternalBlack
Copy link

I currently use Macaw 0.9.3. and cant seem to get the contentMode working (MacawView and SVGView)

Neither via storyboard, nor via code. It kinda seems like I'm missing something.

import UIKit
import Macaw

class SVGViewController: UIViewController {

    @IBOutlet weak var macaw: MacawView!
    @IBOutlet weak var svgView: SVGView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let tiger = try! SVGParser.parse(resource: "tiger")
        self.macaw.node = tiger
        self.macaw.backgroundColor = .darkGray
        self.macaw.contentMode = .scaleToFill

        self.svgView.node = tiger
        self.svgView.backgroundColor = .darkGray
        self.svgView.contentMode = .scaleToFill
    }
}

The tiger.svg is shown on both but seems to be using .scaleAspectFit (by default I guess).

Big Scope:
What I'm actually trying to archive is masking a UIView with and SVG file. but therefor I need the SVG to .scaleToFill the other view (i.e. svgView.contentMode = .scaleToFill; svgView.frame = content.frame`; content.mask = svgView;)

@amarunko
Copy link
Contributor

amarunko commented Jan 9, 2019

Hi, @EternalBlack, it looks extraordinary, can you attach the test project with your config?

@EternalBlack
Copy link
Author

Hey @amarunko,
I actually used the example project with no changes but adding the viewController you see above with the two UIViews connected to the IBOutlets.

@amarunko
Copy link
Contributor

amarunko commented Jan 10, 2019

Tiger SVG contains view box param, when SVG includes this parameter, Macaw using different layout - SVGNodeLayout. Can you try any SVG without view box? I check for 0.9.3 version. For me works as expected. You can read about Macaw content layout here.

@EternalBlack
Copy link
Author

@amarunko Thanks for the hint! Removing the viewbox from the SVG does the trick.

I previously found (searching for contentMode inside the repo) #218 and somewhat expected the tiger.svg to work as it seemed to work back there. Are there any plans to reimplement the contentMode for SVGs with a viewbox? Or is #218 misleading?

Would be nice to add this important/required info to the docs. :)

@ystrot
Copy link
Member

ystrot commented Jan 11, 2019

Hi Markus,

#218 is misleading in this case, because we changed tiger.svg since that time and added viewbox there. I think we'll revert these changes to avoid confusion you mentioned. contentMode works as expected, so we'll update documentation to highlight that in case of viewbox there will be no effect of using contentMode. Thanks for point this out!

@ystrot ystrot self-assigned this Feb 12, 2019
@ystrot ystrot added this to the 0.9.4 milestone Feb 12, 2019
@ystrot ystrot closed this as completed in 28f27a2 Feb 12, 2019
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

3 participants