Refine the settings button of the home view.

// FREEBIE
This commit is contained in:
Matthew Chen 2017-02-17 12:00:10 -05:00
parent 29b30099a0
commit b1744c2b4a
16 changed files with 41 additions and 49 deletions

View File

@ -2,17 +2,17 @@
"images" : [
{
"idiom" : "universal",
"filename" : "phone_white_thin@1x.png",
"filename" : "button_settings_white@1x.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "phone_white_thin@2x.png",
"filename" : "button_settings_white@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "phone_white_thin@3x.png",
"filename" : "button_settings_white@3x.png",
"scale" : "3x"
}
],

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -1,23 +0,0 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "settings_white_thin@1x.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "settings_white_thin@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "settings_white_thin@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -1,23 +0,0 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "timer_white_thin@1x.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "timer_white_thin@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "timer_white_thin@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -138,6 +138,44 @@ NSString *const SignalsViewControllerSegueShowIncomingCall = @"ShowIncomingCallS
selector:@selector(handleDismissCallInterstitialNotification:)
name:[CallService dismissCallInterstitialNotificationName]
object:nil];
[self updateBarButtonItems];
}
- (void)updateBarButtonItems {
const CGFloat kBarButtonSize = 44;
if (YES) {
// We use UIButtons with [UIBarButtonItem initWithCustomView:...] instead of
// UIBarButtonItem in order to ensure that these buttons are spaced tightly.
// The contents of the navigation bar are cramped in this view.
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *image = [UIImage imageNamed:@"button_settings_white"];
[button setImage:image
forState:UIControlStateNormal];
UIEdgeInsets imageEdgeInsets = UIEdgeInsetsZero;
// We normally would want to use left and right insets that ensure the button
// is square and the icon is centered. However UINavigationBar doesn't offer us
// control over the margins and spacing of its content, and the buttons end up
// too far apart and too far from the edge of the screen. So we use a smaller
// left inset tighten up the layout.
imageEdgeInsets.right = round((kBarButtonSize - image.size.width) * 0.5f);
imageEdgeInsets.left = round((kBarButtonSize - (image.size.width + imageEdgeInsets.right)) * 0.25f);
imageEdgeInsets.top = round((kBarButtonSize - image.size.height) * 0.5f);
imageEdgeInsets.bottom = round(kBarButtonSize - (image.size.height + imageEdgeInsets.top));
button.imageEdgeInsets = imageEdgeInsets;
button.accessibilityLabel = NSLocalizedString(@"OPEN_SETTINGS_BUTTON", "Label for button which opens the settings UI");
[button addTarget:self
action:@selector(settingsButtonPressed:)
forControlEvents:UIControlEventTouchUpInside];
button.frame = CGRectMake(0, 0,
round(image.size.width + imageEdgeInsets.left + imageEdgeInsets.right),
round(image.size.height + imageEdgeInsets.top + imageEdgeInsets.bottom));
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
}
}
- (void)settingsButtonPressed:(id)sender {
[self performSegueWithIdentifier:@"ShowAppSettingsSegue" sender:sender];
}
- (UIViewController *)previewingContext:(id<UIViewControllerPreviewing>)previewingContext