-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainViewController.m
85 lines (68 loc) · 2.97 KB
/
MainViewController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
Copyright (C) 2015 Apple Inc. All Rights Reserved.
See LICENSE.txt for this sample’s licensing information
Abstract:
The application's main (initial) view controller.
*/
#import "MainViewController.h"
@interface MainViewController () <UIActionSheetDelegate>
@end
@implementation MainViewController
//| ----------------------------------------------------------------------------
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
//| ----------------------------------------------------------------------------
// Unwind action that is targeted by the demos which present a modal view
// controller, to return to the main screen.
//
- (IBAction)unwindToMainViewController:(UIStoryboardSegue*)sender
{ }
#pragma mark -
#pragma mark Style Action Sheet
//| ----------------------------------------------------------------------------
- (void)actionSheet:(UIActionSheet *)modalView clickedButtonAtIndex:(NSInteger)buttonIndex
{
// Change the navigation bar style
switch (buttonIndex)
{
case 0: // "Default"
self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
// Bars are translucent by default.
self.navigationController.navigationBar.translucent = YES;
// Reset the bar's tint color to the system default.
self.navigationController.navigationBar.tintColor = nil;
break;
case 1: // "Black Opaque"
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
self.navigationController.navigationBar.translucent = NO;
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
break;
case 2: // "Black Translucent"
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
self.navigationController.navigationBar.translucent = YES;
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
break;
}
// Ask the system to re-query our -preferredStatusBarStyle.
[self setNeedsStatusBarAppearanceUpdate];
}
//| ----------------------------------------------------------------------------
//! IBAction for the 'Style' bar button item.
//
- (IBAction)styleAction:(id)sender
{
UIActionSheet *styleAlert = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"Choose a UIBarStyle:", @"")
delegate:self
cancelButtonTitle:NSLocalizedString(@"Cancel", @"")
destructiveButtonTitle:nil
otherButtonTitles:NSLocalizedString(@"Default", @""),
NSLocalizedString(@"Black Opaque", @""),
NSLocalizedString(@"Black Translucent", @""),
nil];
// use the same style as the nav bar
styleAlert.actionSheetStyle = (UIActionSheetStyle)self.navigationController.navigationBar.barStyle;
[styleAlert showInView:self.view];
}
@end