From 7f677e870186073d0d6dad8d37738a32a4b876a9 Mon Sep 17 00:00:00 2001 From: Kevin Wilkinson Date: Sun, 6 Dec 2015 18:31:53 -0500 Subject: [PATCH] finished requirements for button fun --- Button Fun.xcodeproj/project.pbxproj | 9 ++++ .../xcdebugger/Breakpoints_v2.xcbkptlist | 5 ++ Button Fun/Base.lproj/Main.storyboard | 8 ++-- Button Fun/ColorButton.h | 12 +++++ Button Fun/ColorButton.m | 46 +++++++++++++++++++ Button Fun/Info.plist | 4 +- Button Fun/ViewController.h | 2 +- Button Fun/ViewController.m | 38 ++++++++++++++- 8 files changed, 116 insertions(+), 8 deletions(-) create mode 100644 Button Fun.xcodeproj/xcuserdata/Kevin.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist create mode 100644 Button Fun/ColorButton.h create mode 100644 Button Fun/ColorButton.m diff --git a/Button Fun.xcodeproj/project.pbxproj b/Button Fun.xcodeproj/project.pbxproj index 6e72079..733d7f4 100644 --- a/Button Fun.xcodeproj/project.pbxproj +++ b/Button Fun.xcodeproj/project.pbxproj @@ -15,6 +15,7 @@ 0A6661D91C14EDD700CB344A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0A6661D71C14EDD700CB344A /* LaunchScreen.storyboard */; }; 0A6661E41C14EDD700CB344A /* Button_FunTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A6661E31C14EDD700CB344A /* Button_FunTests.m */; }; 0A6661EF1C14EDD700CB344A /* Button_FunUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A6661EE1C14EDD700CB344A /* Button_FunUITests.m */; }; + 0A6661FE1C14F21E00CB344A /* ColorButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A6661FD1C14F21E00CB344A /* ColorButton.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -51,6 +52,8 @@ 0A6661EA1C14EDD700CB344A /* Button FunUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Button FunUITests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 0A6661EE1C14EDD700CB344A /* Button_FunUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Button_FunUITests.m; sourceTree = ""; }; 0A6661F01C14EDD700CB344A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 0A6661FD1C14F21E00CB344A /* ColorButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ColorButton.m; sourceTree = ""; }; + 0A6661FF1C14F23500CB344A /* ColorButton.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ColorButton.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -110,6 +113,8 @@ 0A6661D71C14EDD700CB344A /* LaunchScreen.storyboard */, 0A6661DA1C14EDD700CB344A /* Info.plist */, 0A6661C91C14EDD700CB344A /* Supporting Files */, + 0A6661FD1C14F21E00CB344A /* ColorButton.m */, + 0A6661FF1C14F23500CB344A /* ColorButton.h */, ); path = "Button Fun"; sourceTree = ""; @@ -273,6 +278,7 @@ 0A6661D11C14EDD700CB344A /* ViewController.m in Sources */, 0A6661CE1C14EDD700CB344A /* AppDelegate.m in Sources */, 0A6661CB1C14EDD700CB344A /* main.m in Sources */, + 0A6661FE1C14F21E00CB344A /* ColorButton.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -498,6 +504,7 @@ 0A6661F51C14EDD700CB344A /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; 0A6661F61C14EDD700CB344A /* Build configuration list for PBXNativeTarget "Button FunTests" */ = { isa = XCConfigurationList; @@ -506,6 +513,7 @@ 0A6661F81C14EDD700CB344A /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; 0A6661F91C14EDD700CB344A /* Build configuration list for PBXNativeTarget "Button FunUITests" */ = { isa = XCConfigurationList; @@ -514,6 +522,7 @@ 0A6661FB1C14EDD700CB344A /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/Button Fun.xcodeproj/xcuserdata/Kevin.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Button Fun.xcodeproj/xcuserdata/Kevin.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..fe2b454 --- /dev/null +++ b/Button Fun.xcodeproj/xcuserdata/Kevin.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,5 @@ + + + diff --git a/Button Fun/Base.lproj/Main.storyboard b/Button Fun/Base.lproj/Main.storyboard index f56d2f3..67fd9dd 100644 --- a/Button Fun/Base.lproj/Main.storyboard +++ b/Button Fun/Base.lproj/Main.storyboard @@ -1,13 +1,14 @@ - + - + + - + @@ -15,6 +16,7 @@ + diff --git a/Button Fun/ColorButton.h b/Button Fun/ColorButton.h new file mode 100644 index 0000000..4747134 --- /dev/null +++ b/Button Fun/ColorButton.h @@ -0,0 +1,12 @@ +// +// ColorButton.h +// Button Fun +// +// Created by Kevin on 12/6/15. +// Copyright © 2015 Kevin. All rights reserved. +// +#import + +@interface ColorButton : UIView + +@end diff --git a/Button Fun/ColorButton.m b/Button Fun/ColorButton.m new file mode 100644 index 0000000..a8fa467 --- /dev/null +++ b/Button Fun/ColorButton.m @@ -0,0 +1,46 @@ +// +// ColorButton.m +// Button Fun +// +// Created by Kevin on 12/6/15. +// Copyright © 2015 Kevin. All rights reserved. +// + +#import +#import "ColorButton.h" + +@implementation ColorButton + +-(instancetype)init +{ + if (self = [super init]) + { + UITapGestureRecognizer *tapGR; + tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)]; + tapGR.numberOfTapsRequired = 1; + [self addGestureRecognizer:tapGR]; + + self.frame = CGRectMake(0, 0, 40, 40); + + [self setRandomColor]; + } + return self; +} + +-(void)handleTap:(UITapGestureRecognizer*)sender +{ + [self setRandomColor]; +} + +-(void)setRandomColor +{ + float red = (float)rand() / RAND_MAX; + float blue = (float)rand() / RAND_MAX; + float green = (float)rand() / RAND_MAX; + + self.backgroundColor = [UIColor colorWithRed:red green:green blue:blue alpha:1.0]; + +} + +@end + diff --git a/Button Fun/Info.plist b/Button Fun/Info.plist index 40c6215..05b9398 100644 --- a/Button Fun/Info.plist +++ b/Button Fun/Info.plist @@ -30,11 +30,11 @@ armv7 + UIStatusBarHidden + UISupportedInterfaceOrientations UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight UISupportedInterfaceOrientations~ipad diff --git a/Button Fun/ViewController.h b/Button Fun/ViewController.h index 833dade..48e943a 100644 --- a/Button Fun/ViewController.h +++ b/Button Fun/ViewController.h @@ -9,7 +9,7 @@ #import @interface ViewController : UIViewController - +@property (strong, nonatomic) NSArray* buttonsArray; @end diff --git a/Button Fun/ViewController.m b/Button Fun/ViewController.m index 7102c30..62979cd 100644 --- a/Button Fun/ViewController.m +++ b/Button Fun/ViewController.m @@ -7,6 +7,7 @@ // #import "ViewController.h" +#import "ColorButton.h" @interface ViewController () @@ -16,12 +17,45 @@ @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; - // Do any additional setup after loading the view, typically from a nib. + + if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) { + [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)]; + } +} + +- (BOOL)prefersStatusBarHidden { + return YES; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. } +- (void)viewDidAppear:(BOOL)animated +{ + [super viewDidAppear:animated]; + [self setupButtons]; +} + +-(void)setupButtons +{ + int buttonsWide = self.view.bounds.size.width / 40; + int buttonsTall = self.view.bounds.size.height / 40; + NSMutableArray* mutButtonsArray = [[NSMutableArray alloc] init]; + + for (int i = 0; i <= buttonsWide; i++) + { + for (int j = 0; j <= buttonsTall; j++) + { + ColorButton* button = [[ColorButton alloc]init]; + button.frame = CGRectMake(i * 40, j * 40, 40, 40); + [self.view addSubview:button]; + [mutButtonsArray addObject:button]; + } + } + + self.buttonsArray = mutButtonsArray; +} + + @end