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).

 

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;
        }];
    }
}

IBOutlets should always be weak

Leave a comment

Pair just reminding me that IBOutlets should always be weak.

But if you create an object and programmatically yourself they can be strong.

How to reuse UITableViewCell

Leave a comment

This is magic. Say you have a table cell with controls, and you want to reuse it without keeping a reference to it explicitly in your ViewController. Do this.

Get your cell as normal, but add any selectors you need to it when it’s being created, and then tag it with the index row number of the table.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
SPTMessagePreviewTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"PreviewPortraitCell"];

[cell.playButton addTarget:self action:@selector(playButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
cell.playButton.tag = indexPath.row;

return cell;
}

Then, later on in your button method, dequeue it and get the same cell back.

- (IBAction)playButtonPressed:(UIButton *)sender
{
    // dequeue cell by tag and update progress bar
    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:sender.tag inSection:0];
    SPTMessagePreviewTableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
    [cell updatePlaybackSliderForPlayer:self.player];
}

This is beautiful because now you can push functionality into your cell, and call it from your ViewController.

Older Entries

%d bloggers like this: