Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Dr. Mickey Lauer mickeyl

🏠
Working from home
View GitHub Profile
@mickeyl
mickeyl / UIImage+PSPDFKitAdditions.m
Created Sep 24, 2020 — forked from steipete/UIImage+PSPDFKitAdditions.m
Preload UIImage for super-smooth interaction. especially great if you use JPGs, which otherwise produce a noticeable lag on the main thread.
View UIImage+PSPDFKitAdditions.m
- (UIImage *)pspdf_preloadedImage {
CGImageRef image = self.CGImage;
// make a bitmap context of a suitable size to draw to, forcing decode
size_t width = CGImageGetWidth(image);
size_t height = CGImageGetHeight(image);
CGColorSpaceRef colourSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef imageContext = CGBitmapContextCreate(NULL, width, height, 8, width*4, colourSpace,
kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little);
@mickeyl
mickeyl / SomeUITableViewCell.m
Last active Aug 20, 2016
Work around a crash in UITableView when changing layout during scrolling
View SomeUITableViewCell.m
-(void)triggerRelayoutIfNecessary
{
[_activityIndicator stopAnimating];
float newHeight = [self.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
if ( newHeight != _lastHeight )
{
UITableView* tv = (UITableView*)[self LT_findFirstSuperviewOfClass:UITableView.class];
if ( tv.isDragging || tv.isDecelerating )
{
@mickeyl
mickeyl / NSString+Extensions.h
Created Mar 11, 2016
A taste of Python in Objective-C
View NSString+Extensions.h
@implementation NSString (IndexedSubscripting)
-(NSString*)objectAtIndexedSubscript:(NSInteger)index
{
NSRange range = NSMakeRange( index < 0 ? self.length + index: index, 1 );
return [self substringWithRange:range];
}
@end
@mickeyl
mickeyl / LTLabel.m
Last active Mar 11, 2016
Poor man's UIStackView :)
View LTLabel.m
-(CGSize)intrinsicContentSize
{
if ( _zeroIntrinsicContentSizeIfHidden && self.hidden )
{
return CGSizeZero;
}
return [super intrinsicContentSize];
}