How to create spherical gradient for title page Illustrator

Leave a comment

Say you want a nice soft glow in the background of your title page.

Screen Shot 2017-02-25 at 2.08.23 PM.png

Do this. Draw a square.

Screen Shot 2017-02-25 at 2.10.38 PM.png

Click Gradient from the Window menu

Screen Shot 2017-02-25 at 2.11.32 PM.png

Then click the gradient button to apply a gradient to your square. And then select ‘radial’ to make it spread out.

Screen Shot 2017-02-25 at 2.12.45 PM.png

Now the trick with making it spread out, it to press ‘g’ and then manually drag the end point of the gradient meter out beyond the square.

Screen Shot 2017-02-25 at 2.19.51 PM.png

Once you learn how to do that, you create create pretty much any gradient you want. Just grab the gradient tool, move it around, and try different things out.

Links that help

Trouble Shooting

If for some reason you find the gradient tool isn’t allowing you to change the gradient (i.e. pressing ‘g’ and then locking you out…toggle the fill stroke switch in the gradient window.

Screen Shot 2017-02-25 at 2.07.13 PM.png

Chances are you have stroke activated when what you really want is fill (or vice versa).

 

Why I write automated tests

Leave a comment

Why I write automated tests.

I write automated tests for a variety of reasons. For one they tell me when I break things. Secondly, having automated tests enables me to go fast. I can make changes with confidence. I am free to aggressively refactor my design. And I don’t stress about breaking the important stuff because I know the automated tests are there to back me up. They are like my shield and my armour.

But really, to me, automated tests are about leverage. They allow me to leverage myself in greater ways that wouldn’t be possible if they weren’t there. I can spend less time regression testing. More time adding new features, improving the testing while doing the one other kind of testing that’s really important – exploratory. These are things things the computer can’t do. Only I can.

So for me automated tests are about leverage. They give us a way to leverage ourselves and our teams further, while giving us all back the one thing we crave. Time.

How to add iOS Xcode subprojects abbreviated

Leave a comment

If you want to add another iOS project to your existing subproject, at a minimum do this. Find the project you want to add

Screen Shot 2017-02-23 at 1.19.43 PM.png

Drag it into your project

Screen Shot 2017-02-23 at 1.20.28 PM.png

Goto the target you want to add it to -> Build Phases.

Add Target Dependency (hit the + sign)

Screen Shot 2017-02-23 at 1.21.54 PM.png

Link Binary With Libraries (+ sign)

Screen Shot 2017-02-23 at 1.22.29 PM.png

Build/Compile. You should now be good to go.

Links that help

https://agilewarrior.wordpress.com/2016/04/04/how-to-add-xcode-subproject/

https://agilewarrior.wordpress.com/2016/12/22/how-to-create-universal-static-library-ios/

How to quickly clear derived data

Leave a comment

Xcode -> Preferences -> Locations -> little grey arrow that is hard to see

Screen Shot 2017-02-23 at 1.18.26 PM.png

Screen Shot 2017-02-23 at 1.18.41 PM.png

Then physically delete the directory in finder

Screen Shot 2017-02-23 at 1.19.00 PM.png

How to share data App Extension

Leave a comment

How to share data between App Extension and Host

Since app extensions run as part of a host application rather than their containing app (i.e. your app extension runs in somebody elses app), data sharing isn’t automatic.

App extensions and hosts can share data via App Groups. App Groups are shared containers both App Extensions and Hosts can use to communicate with each other since no direct communication is allowed.

Setting up an App Group

App Groups are the scheme iOS uses to allow different apps to share data. If you have the right entitlements and proper provisioning, they can access a shared directory outside their normal iOS sandbox.

Create a new SingleView app.

Screen Shot 2017-02-14 at 1.29.21 PM.png

Go Capabilities and turn on App Groups.

Screen Shot 2017-02-14 at 1.29.50 PM.png

Screen Shot 2017-02-14 at 1.29.54 PM.png

Now you can share data like this.

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    NSUserDefaults *myDefaults = [[NSUserDefaults alloc]
                                  initWithSuiteName:@"group.spike.AppGroupNSUserDefaults"];
    [myDefaults setObject:@"foo" forKey:@"bar"];
    NSLog(@"\n\nWrote it!\n\n\n");
}

Add an App Extension

Now let’s add an app extension and try this out. New Target -> iMessage Extension.

Note: This will automatically setup a sub bundle id that should work for you out of the box. Bundle ids are important and this must be nested.

Screen Shot 2017-02-14 at 1.31.31 PM.png

It will also create an entitlements file

Screen Shot 2017-02-14 at 1.31.36 PM.png

Turn on App Groups for your newly created App Extension

Screen Shot 2017-02-14 at 1.32.09 PM.png

And now try reading something from NSUserDefaults written by your container app.

- (void)viewDidLoad {
    [super viewDidLoad];
    NSUserDefaults *myDefaults = [[NSUserDefaults alloc]
                                  initWithSuiteName:@"group.spike.AppGroupNSUserDefaults"];
    NSString *value = [myDefaults objectForKey:@"bar"];
    NSLog(@"\n\n\nvalue: %@\n\n\n", value);
}

 Screen Shot 2017-02-14 at 1.33.26 PM.png

Links that help

https://developer.apple.com/library/content/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios.html#//apple_ref/doc/uid/TP40014214-CH21-SW1

http://www.atomicbird.com/blog/sharing-with-app-extensions

How to animate view iOS

Leave a comment

- (void)showErrorView
{
    if (self.errorView.hidden) {
        self.errorView.alpha = 0.0;
        self.errorView.hidden = NO;

        [UIView animateWithDuration:0.3 animations:^{
            self.contentView.alpha = 0.0;
            self.errorView.alpha = 1.0;
        } completion:^(BOOL finished) {
            self.contentView.hidden = YES;
            self.noResultsView.hidden = YES;
            self.offlineView.hidden = YES;
        }];
    }
}

Beautiful code is good method composition

Leave a comment

Was listening to a podcast with DHH on Tim Ferris show and I really like his definition of beautiful code.

Basically said it’s code where all the methods and abstractions in a class are at the same level. Some methods aren’t doing really low level things. Others aren’t too high. They are all at the same level of abstraction.

Good way to describe any nice API.

For example you can do this:

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupDelegates];
    [self setupLayouts];
    [self setupSearchBar];
    [self setupReachability];
    [self displayTracks];
}

Or you can do this

- (void)viewDidLoad {
    [super viewDidLoad];
    self.searchBar.delegate = self;
    self.collectionView.delegate = self;
    self.collectionView.collectionViewLayout = self.collectionFlowLayout;
    [self setupSearchBar];
    [self setupReachability];
    [self displayTracks];
}

See the difference? The methods are not all at the same level of abstraction. Which makes the code harder to read.

Older Entries

%d bloggers like this: