Tell When a UIPageViewController is Scrolling (for Parallax Scrolling of an Image)

for (UIView *view in self.pageViewController.view.subviews) { if ([view isKindOfClass:[UIScrollView class]]) { [(UIScrollView *)view setDelegate:self]; } } this gives you access to all standard scroll view API methods. And this is not using private Apple API’s. I added traversing through subviews, to 100% find the UIPageViewController‘s inner scroll view WARNING: Be careful with scrollview.contentOffset. It resets … Read more

How can I tint a UIImage with gradient?

EDIT: Here is a version which supports non-retina and retina displays The method can be used as a category for UIImage + (UIImage *)imageWithGradient:(UIImage *)img startColor:(UIColor *)color1 endColor:(UIColor *)color2 { UIGraphicsBeginImageContextWithOptions(img.size, NO, img.scale); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextTranslateCTM(context, 0, img.size.height); CGContextScaleCTM(context, 1.0, -1.0); CGContextSetBlendMode(context, kCGBlendModeNormal); CGRect rect = CGRectMake(0, 0, img.size.width, img.size.height); //CGContextDrawImage(context, rect, img.CGImage); … Read more

Adding Images to UIActionSheet buttons as in UIDocumentInteractionController

There is a possibility to add images (to be exact: icons or symbols) to the buttons of a UIActionSheet (or a UIAlertView) without loading image files or fiddling around with (sub)views. In these classes buttons are specified by their titles, which are strings. So it is obvious to use symbols, which one can specify also … Read more

Stretch background image for UIButton

From the example images you provided I’m pretty sure you’re looking for UIImage‘s resizableImageWithCapInsets: UIImage *originalImage = [UIImage imageNamed:@”myImage.png”]; UIEdgeInsets insets = UIEdgeInsetsMake(top, left, bottom, right); UIImage *stretchableImage = [originalImage resizableImageWithCapInsets:insets]; [myButton setBackgroundImage:stretchableImage forState:UIControlStateNormal]; // the image will be stretched to fill the button, if you resize it. The values in the UIEdgeInsets struct determine … Read more

tech