#ios

inputAccessoryView ignores bottom Safe Area in iPhone X's

I have this neat view controller setup for my comments system. At the bottom of the screen is inputAccessoryView which will be fixed until interacted with to bring keypad up for user to post comments. When keypad is up view will be above it and if keypad is dismissed then view will stick at the bottom of screen.

To achieve this I override two methods of my UIViewController:


-(BOOL)canBecomeFirstResponder{
    return YES;
}

-(UIView *)inputAccessoryView{
    return commentInputView.contentView;
}

I am using custom xib and my custom input view is composed within the class.

It works fine except in iPhone with notch.

CONTINUE READING

Failed Automatic Size of UICollectionViewCell in iOS 12

The content of my UICollectionView flows in horizontal direction. Height of items are fixed but width of each are dynamic based on the length of text. For this example I am using only UILabel in my UICollectionViewCell. My UICollectionViewCell is custom xib.

These are the constraints I have applied to UILabel:
  • Leading : 0
  • Trailing : 0
  • Top : 0
  • Height : 44

CONTINUE READING

Blurry Pixel Font: SpriteKit

It's amazing how modern Pixel Art captures the true simplicity yet also expressing creative masterpieces. I find so much solace staring at the world presented by games like Stardew Valley and Kynseed.

In my spare time I am making 2d pixel art game for iOS and macOS for my hobby. I found a free pixel art font called PixelDigivolve to use it for my texts. There was this behaviour that caught my attention where font was being rendered very blurry. The edges were not sharp.

CONTINUE READING

Sorting NSArray of custom objects with more nesting

Sorting an array of custom objects is fair simple. NSSortDescriptor works awesome for this. Lets see an example:


@interface Parent : NSObject
@property(strong, nonatomic) NSString *name;
@end
NSArray *arrayOfParents = @[parent1, parent2];

If I want to sort array of parents by their name then I would use something like:

CONTINUE READING

drawViewHierarchyInRect vs renderInContext

I came across very curious problem whose cause I couldn’t have come to know about it without serious debugging because this was something that didn’t catch my attention. I had a task that required capturing snapshot of UIView with hierarchy of subviews and perform few interactive transformation animations on view immediately after - giving feeling of instant multitask. Delay should have been negligent for naked eyes or tolerant but it wasn’t.

CONTINUE READING