Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Button Fun.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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 = "<group>"; };
0A6661F01C14EDD700CB344A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
0A6661FD1C14F21E00CB344A /* ColorButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ColorButton.m; sourceTree = "<group>"; };
0A6661FF1C14F23500CB344A /* ColorButton.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ColorButton.h; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -110,6 +113,8 @@
0A6661D71C14EDD700CB344A /* LaunchScreen.storyboard */,
0A6661DA1C14EDD700CB344A /* Info.plist */,
0A6661C91C14EDD700CB344A /* Supporting Files */,
0A6661FD1C14F21E00CB344A /* ColorButton.m */,
0A6661FF1C14F23500CB344A /* ColorButton.h */,
);
path = "Button Fun";
sourceTree = "<group>";
Expand Down Expand Up @@ -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;
};
Expand Down Expand Up @@ -498,6 +504,7 @@
0A6661F51C14EDD700CB344A /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
0A6661F61C14EDD700CB344A /* Build configuration list for PBXNativeTarget "Button FunTests" */ = {
isa = XCConfigurationList;
Expand All @@ -506,6 +513,7 @@
0A6661F81C14EDD700CB344A /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
0A6661F91C14EDD700CB344A /* Build configuration list for PBXNativeTarget "Button FunUITests" */ = {
isa = XCConfigurationList;
Expand All @@ -514,6 +522,7 @@
0A6661FB1C14EDD700CB344A /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
</Bucket>
8 changes: 5 additions & 3 deletions Button Fun/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6211" systemVersion="14A298i" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9060" systemVersion="15A284" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6204"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9051"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="" sceneMemberID="viewController">
<viewController id="BYZ-38-t0r" customClass="ViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</viewController>
Expand Down
12 changes: 12 additions & 0 deletions Button Fun/ColorButton.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// ColorButton.h
// Button Fun
//
// Created by Kevin on 12/6/15.
// Copyright © 2015 Kevin. All rights reserved.
//
#import <UIKit/UIKit.h>

@interface ColorButton : UIView

@end
46 changes: 46 additions & 0 deletions Button Fun/ColorButton.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// ColorButton.m
// Button Fun
//
// Created by Kevin on 12/6/15.
// Copyright © 2015 Kevin. All rights reserved.
//

#import <Foundation/Foundation.h>
#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

4 changes: 2 additions & 2 deletions Button Fun/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
<array>
<string>armv7</string>
</array>
<key>UIStatusBarHidden</key>
<true/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
Expand Down
2 changes: 1 addition & 1 deletion Button Fun/ViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#import <UIKit/UIKit.h>

@interface ViewController : UIViewController

@property (strong, nonatomic) NSArray* buttonsArray;

@end

38 changes: 36 additions & 2 deletions Button Fun/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

#import "ViewController.h"
#import "ColorButton.h"

@interface ViewController ()

Expand All @@ -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