Do you keep a fork of all the GitHub projects you use? Even if you’re not planning to make changes, this is useful because the original might disappear one day. The drawback is that you will most likely need to update your fork from time to time.
Of course, you can sync your fork with the original using git from the terminal. However, GitHub also made it very easy to do this directly from the website. It takes a few clicks, and I find it more convenient when I’m with limited connectivity.
Here’s how to update your fork directly from GitHub (as shown in the video above):
Open your fork on GitHub.
Click on Pull Requests.
Click on New Pull Request. By default, GitHub will compare the original with your fork, and there shouldn’t be anything to compare if you didn’t make any changes.
Click on switching the base. Now GitHub will compare your fork with the original, and you should see all the latest changes.
Click on Click to create a pull request for this comparison and assign a predictable name to your pull request (e.g., Update from original).
Click on Send pull request.
Scroll down and click Merge pull request and finally Confirm merge. If your fork didn’t have any changes, you will be able to merge it automatically.
GitHub is increasingly enabling users to collaborate without using git. I find this fascinating, as it puts the power of open source collaboration on the hands of people who might not be developers. And that is a great thing.
RMShapedImageView is a UIImage subclass that overrides pointInside:withEvent:. This method is called to determine if a touch is inside the view. In our case, we only want to return YES if the corresponding pixels are not transparent (alpha > 0).
Add RMShapedImageView.h and RMShapedImageView.m to your project.
Replace your UIImageView with RMShapedImageView either in code or Interface Builder (by setting the Class of your UIImageView to RMShapedImageView).
RMShapedImageView works with retina and non-retina images, as well as transformed views. It’s particularly useful is you’re using gesture recognisers. Currently supports only two content modes: UIViewContentModeScaleToFill and UIViewContentModeTopLeft. More will be added in time.
Touches are inexact things and querying the alpha value of a single pixel might be too strict, even more so if the image is scaled down. Furthermore, if the image has shadows you might also want to ignore touches on them. RMShapedImageView has two configuration options to work around these problems:
shapedTransparentMaxAlpha: maximum alpha value that will be considered transparent. 0 by default.
shapedPixelTolerance: number of pixels around the point that will be examined. If at least one of them has alpha bigger than shapedTransparentMaxAlphapointInside:withEvent: will return YES. 0 by default.
The project also includes a demo and bare-bones unit tests and is distributed under the Apache License 2.0. You’re more than welcome to fork it and improve.