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

how to center pulse behind image #17

Closed
ghost opened this issue Jan 13, 2017 · 5 comments
Closed

how to center pulse behind image #17

ghost opened this issue Jan 13, 2017 · 5 comments

Comments

@ghost
Copy link

ghost commented Jan 13, 2017

the pulse is on the top left of the image i can add it to the center of the image.
thank you in advance
screen shot 2017-01-13 at 4 46 33 am

@marciliojrs
Copy link

override func viewDidLoad() {
    ...
    imageView.layer.superlayer?.insertSublayer(pulsator, below: imageView.layer)
    ...
}

override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()

    pulsator.position = imageView.layer.position
}

@shu223
Copy link
Owner

shu223 commented Mar 25, 2017

I hope this was resolved. Thanks @marciliojrs for your support!

@SirWellington
Copy link

I believe this should be centered by default as well, or at the very least customizable by the API.

@dmwesterhoff
Copy link

dmwesterhoff commented Feb 26, 2020

I added this line and it set the position correctly:

pulsator.position = sourceView.layer.position

That way I didn't need to override that method out just to correct the position, not sure if there is ramifications to this method for other use cases but it worked as well in my case and isolated my code to a single method.

--
It might be nice to provided a convenience initialization method for the element, since drawing behind and center to another view is a common (most used?) use case. That could make the API more friendly for the norm

@LoopingLouieX
Copy link

LoopingLouieX commented Jul 8, 2020

I've added the following code and that worked for me:
pulsator.position = CGPoint(x: yourView.bounds.width / 2, y: yourView.bounds.height / 2)

There's also a center property available, so this works too:
pulsator.position = yourView.center

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

5 participants