Skip to content

Instantly share code, notes, and snippets.

View radianttap's full-sized avatar
馃
路 路 路

Aleksandar Vaci膰 radianttap

馃
路 路 路
View GitHub Profile
@radianttap
radianttap / NeverCreateTabsLikeThis.mm
Created January 23, 2013 16:15
Never initialize multiple UICollectionViewControllers with the same UICollectionViewLayout instance
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// this subclass defines itemsSize as {320, 88}
MyUICollectionViewFlowLayout *l = [[MyUICollectionViewFlowLayout alloc] init];
// initialize one subclass of UICollectionViewController
MainViewController *mvc = [[MainViewController alloc] initWithCollectionViewLayout:l];
// initialize another with same layout
// but inside this init method do:
@radianttap
radianttap / gist:4484269
Last active December 10, 2015 19:48 — forked from anonymous/gist:4468522
Pulse view
+ (void)pulseView:(UIView *)view completion:(void (^)(void))block {
// if you use auto layout, view-based transform go haywire, as they trigger layoutSubviews
// consequence is that you have no idea where the view will end up on the screen once animation completes
// see this discussion: http://stackoverflow.com/questions/12943107/how-do-i-adjust-the-anchor-point-of-a-calayer-when-auto-layout-is-being-used
// thus (per solution 4 from link above), rewriting with CAKeyframeAnimation
CAKeyframeAnimation *ka = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
ka.duration = .49;
@radianttap
radianttap / gist:4455176
Last active August 16, 2018 08:52
Inserting child controllers in the Auto-Layout world.
// ## inserting. this can be done in viewDidLoad
// this can be any view, here I'm adding to main view
UIView *containerView = self.view;
// load child controller
UIViewController *svc = [[UIViewController alloc] initWithNibName:nil bundle:nil];
// kill the randomness
svc.view.translatesAutoresizingMaskIntoConstraints = NO;
// add child VC to hierarchy
[self addChildViewController:svc];
// set initial rect
@radianttap
radianttap / AppleiOS6MapsLegallink.m
Created September 17, 2012 10:47
Remove Legal link in Apple Maps