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

It appears that the calculation for point inside is not correct when the button image dimensions do not match the button size dimensions #1

Closed
jayson-h opened this issue Feb 22, 2011 · 7 comments

Comments

@jayson-h
Copy link

It appears that the code does not account for image sizes that do not match the button size (probably only applies to development builds as production images should match the button size).

I added the following logic inside of "pointInside" to account for image sizes that do not match the button size (I did not test for Retina Display @2x images). You may be able to design something more elegant.

CGSize iSize = buttonImage.size;
CGSize bSize = self.frame.size;
point.x *= (bSize.width != 0) ? (iSize.width / bSize.width) : 1;
point.y *= (bSize.height != 0) ? (iSize.height / bSize.height) : 1;
@ole
Copy link
Owner

ole commented Feb 23, 2011

Thanks for this. I also received a couple of comments on my blog that my code does not work in all cases. I will try to put some time into this class in the next few weeks.

@ole
Copy link
Owner

ole commented Apr 24, 2011

I finally fixed this.

@ole ole closed this as completed Apr 24, 2011
@ghost
Copy link

ghost commented Aug 12, 2011

u r genius man.awesome

@mark0dark
Copy link

thanks~~

@dby
Copy link

dby commented Oct 17, 2014

really good.. what a genius man. thanks

@pppqppqpphejj
Copy link

handsome boy ,this is there Swift version

@ole
Copy link
Owner

ole commented May 25, 2018

@pppqppqpphejj No. See #11 for an explanation.

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