Skip to content
This repository was archived by the owner on Dec 2, 2020. It is now read-only.

Commit c107658

Browse files
committed
Further fixes for more substantive comments on PR #295
Fix top reference line offset bug Adds categories for UIKit extensions in MasterVC Adds Options title for iPhone version of TestBed Only changes in storyboard due to newer IB
1 parent 0e33b98 commit c107658

8 files changed

Lines changed: 212 additions & 161 deletions

File tree

Classes/BEMLine.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ - (void)drawRect:(CGRect)rect {
7373

7474
if (self.enableTopReferenceFrameLine) {
7575
// Top Line
76-
[referenceFramePath moveToPoint: CGPointMake(0+offset, offset)];
76+
[referenceFramePath moveToPoint: CGPointMake(0, offset)];
7777
[referenceFramePath addLineToPoint:CGPointMake(self.frame.size.width, offset)];
7878
}
7979

Sample Project/SimpleLineChart.xcodeproj/project.pbxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
1E03A0321EC8BED200CA4247 /* UITextField+Numbers.m in Sources */ = {isa = PBXBuildFile; fileRef = 1E03A0311EC8BED200CA4247 /* UITextField+Numbers.m */; };
11+
1E03A0351EC8BF4C00CA4247 /* UIButton+Switch.m in Sources */ = {isa = PBXBuildFile; fileRef = 1E03A0341EC8BF4C00CA4247 /* UIButton+Switch.m */; };
1012
1E960A851E7DF942000E2BB8 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 1E960A841E7DF942000E2BB8 /* main.m */; };
1113
1E960A881E7DF942000E2BB8 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1E960A871E7DF942000E2BB8 /* AppDelegate.m */; };
1214
1E960A8E1E7DF942000E2BB8 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1E960A8C1E7DF942000E2BB8 /* Main.storyboard */; };
@@ -68,6 +70,10 @@
6870
/* End PBXContainerItemProxy section */
6971

7072
/* Begin PBXFileReference section */
73+
1E03A0301EC8BED200CA4247 /* UITextField+Numbers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UITextField+Numbers.h"; sourceTree = "<group>"; };
74+
1E03A0311EC8BED200CA4247 /* UITextField+Numbers.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UITextField+Numbers.m"; sourceTree = "<group>"; };
75+
1E03A0331EC8BF4C00CA4247 /* UIButton+Switch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIButton+Switch.h"; sourceTree = "<group>"; };
76+
1E03A0341EC8BF4C00CA4247 /* UIButton+Switch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIButton+Switch.m"; sourceTree = "<group>"; };
7177
1E960A811E7DF942000E2BB8 /* TestBed.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TestBed.app; sourceTree = BUILT_PRODUCTS_DIR; };
7278
1E960A841E7DF942000E2BB8 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
7379
1E960A861E7DF942000E2BB8 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
@@ -187,6 +193,10 @@
187193
1E960A9B1E7DF9BB000E2BB8 /* DetailViewController.m */,
188194
1E960A9C1E7DF9BB000E2BB8 /* MasterViewController.h */,
189195
1E960A9D1E7DF9BB000E2BB8 /* MasterViewController.m */,
196+
1E03A0331EC8BF4C00CA4247 /* UIButton+Switch.h */,
197+
1E03A0341EC8BF4C00CA4247 /* UIButton+Switch.m */,
198+
1E03A0301EC8BED200CA4247 /* UITextField+Numbers.h */,
199+
1E03A0311EC8BED200CA4247 /* UITextField+Numbers.m */,
190200
1E960A9E1E7DF9BB000E2BB8 /* StatsViewController.h */,
191201
1E960A9F1E7DF9BC000E2BB8 /* StatsViewController.m */,
192202
1E960AFB1E7F9C80000E2BB8 /* MSColorPicker */,
@@ -482,10 +492,12 @@
482492
1E960AA81E7E0990000E2BB8 /* BEMGraphCalculator.m in Sources */,
483493
1E960AA01E7DF9BC000E2BB8 /* ARFontPickerViewController.m in Sources */,
484494
1E960B171E7F9C80000E2BB8 /* MSHSBView.m in Sources */,
495+
1E03A0351EC8BF4C00CA4247 /* UIButton+Switch.m in Sources */,
485496
1E960B121E7F9C80000E2BB8 /* MSColorComponentView.m in Sources */,
486497
1E960A881E7DF942000E2BB8 /* AppDelegate.m in Sources */,
487498
1E960AA31E7DF9BC000E2BB8 /* StatsViewController.m in Sources */,
488499
1E960AA21E7DF9BC000E2BB8 /* MasterViewController.m in Sources */,
500+
1E03A0321EC8BED200CA4247 /* UITextField+Numbers.m in Sources */,
489501
1E960B141E7F9C80000E2BB8 /* MSColorSelectionViewController.m in Sources */,
490502
1E960B161E7F9C80000E2BB8 /* MSColorWheelView.m in Sources */,
491503
1E960A851E7DF942000E2BB8 /* main.m in Sources */,

Sample Project/TestBed/Base.lproj/Main.storyboard

Lines changed: 92 additions & 92 deletions
Large diffs are not rendered by default.

Sample Project/TestBed/MasterViewController.m

Lines changed: 3 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,8 @@
1010
#import "DetailViewController.h"
1111
#import "ARFontPickerViewController.h"
1212
#import "MSColorSelectionViewController.h"
13-
14-
//some convenience extensions for setting and reading
15-
@interface UITextField (Numbers)
16-
@property (nonatomic) CGFloat floatValue;
17-
@property (nonatomic) NSUInteger intValue;
18-
19-
@end
13+
#import "UITextField+Numbers.h"
14+
#import "UIButton+Switch.h"
2015

2116
@interface MasterViewController () <MSColorSelectionViewControllerDelegate, UIPopoverPresentationControllerDelegate>
2217

@@ -26,67 +21,6 @@ @interface MasterViewController () <MSColorSelectionViewControllerDelegate, UIPo
2621
@property (strong, nonatomic) UIView * currentColorChip;
2722
@end
2823

29-
@implementation UITextField (Numbers)
30-
31-
- (void)setFloatValue:(CGFloat) num {
32-
if (num < 0.0) {
33-
self.text = @"";
34-
} else if (num >= NSNotFound ) {
35-
self.text = @"oopsf";
36-
} else {
37-
self.text = [NSString stringWithFormat:@"%0.1f",num];
38-
}
39-
}
40-
41-
- (void)setIntValue:(NSUInteger) num {
42-
if (num == NSNotFound ) {
43-
self.text = @"";
44-
} else if (num == (NSUInteger)-1 ) {
45-
self.text = @"oops";
46-
}else {
47-
self.text = [NSString stringWithFormat:@"%d",(int)num];
48-
}
49-
}
50-
51-
- (CGFloat)floatValue {
52-
if (self.text.length ==0) {
53-
return -1.0;
54-
} else {
55-
return (CGFloat) self.text.floatValue;
56-
}
57-
}
58-
59-
- (NSUInteger)intValue {
60-
if (self.text.length ==0) {
61-
return NSNotFound;
62-
} else {
63-
return (NSUInteger) self.text.integerValue;
64-
}
65-
66-
}
67-
68-
@end
69-
70-
@interface UIButton (Switch)
71-
@property (nonatomic) BOOL on;
72-
@end\
73-
74-
@implementation UIButton (Switch)
75-
static NSString * checkOff = @"";
76-
static NSString * checkOn = @"";
77-
78-
- (void)setOn: (BOOL) on {
79-
[self setTitle: (on ? checkOn : checkOff) forState:UIControlStateNormal];
80-
}
81-
82-
- (BOOL)on {
83-
if (!self.currentTitle) return NO;
84-
return [checkOff isEqualToString: ( NSString * _Nonnull )self.currentTitle ];
85-
}
86-
87-
@end
88-
89-
9024
@interface MasterViewController () <ARFontPickerViewControllerDelegate, UITextFieldDelegate>
9125

9226
@property (nonatomic) BOOL hasRestoredUI;
@@ -199,6 +133,7 @@ CGGradientRef createGradient () {
199133
- (void)viewDidLoad {
200134
[super viewDidLoad];
201135
// Do any additional setup after loading the view, typically from a nib.
136+
self.title = @"Options";
202137
self.hasRestoredUI = NO;
203138
self.detailViewController = (DetailViewController *)[[self.splitViewController.viewControllers lastObject] topViewController];
204139
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//
2+
// UIButton+Switch.h
3+
// SimpleLineChart
4+
//
5+
// Created by Hugh Mackworth on 5/14/17.
6+
// Copyright © 2017 Boris Emorine. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
11+
@interface UIButton (Switch)
12+
@property (nonatomic) BOOL on;
13+
14+
@end
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//
2+
// UIButton+Switch.m
3+
// SimpleLineChart
4+
//
5+
// Created by Hugh Mackworth on 5/14/17.
6+
// Copyright © 2017 Boris Emorine. All rights reserved.
7+
//
8+
9+
#import "UIButton+Switch.h"
10+
11+
@implementation UIButton (Switch)
12+
static NSString * checkOff = @"";
13+
static NSString * checkOn = @"";
14+
15+
- (void)setOn: (BOOL) on {
16+
[self setTitle: (on ? checkOn : checkOff) forState:UIControlStateNormal];
17+
}
18+
19+
- (BOOL)on {
20+
if (!self.currentTitle) return NO;
21+
return [checkOff isEqualToString: ( NSString * _Nonnull )self.currentTitle ];
22+
}
23+
24+
@end
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// UITextField+Numbers.h
3+
// SimpleLineChart
4+
//
5+
// Created by Hugh Mackworth on 5/14/17.
6+
// Copyright © 2017 Boris Emorine. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
11+
//some convenience extensions for setting and reading
12+
@interface UITextField (Numbers)
13+
@property (nonatomic) CGFloat floatValue;
14+
@property (nonatomic) NSUInteger intValue;
15+
16+
@end
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
//
2+
// UITextField+Numbers.m
3+
// SimpleLineChart
4+
//
5+
// Created by Hugh Mackworth on 5/14/17.
6+
// Copyright © 2017 Boris Emorine. All rights reserved.
7+
//
8+
9+
#import "UITextField+Numbers.h"
10+
11+
@implementation UITextField (Numbers)
12+
13+
- (void)setFloatValue:(CGFloat) num {
14+
if (num < 0.0) {
15+
self.text = @"";
16+
} else if (num >= NSNotFound ) {
17+
self.text = @"oopsf";
18+
} else {
19+
self.text = [NSString stringWithFormat:@"%0.1f",num];
20+
}
21+
}
22+
23+
- (void)setIntValue:(NSUInteger) num {
24+
if (num == NSNotFound ) {
25+
self.text = @"";
26+
} else if (num == (NSUInteger)-1 ) {
27+
self.text = @"oops";
28+
}else {
29+
self.text = [NSString stringWithFormat:@"%d",(int)num];
30+
}
31+
}
32+
33+
- (CGFloat)floatValue {
34+
if (self.text.length ==0) {
35+
return -1.0;
36+
} else {
37+
return (CGFloat) self.text.floatValue;
38+
}
39+
}
40+
41+
- (NSUInteger)intValue {
42+
if (self.text.length ==0) {
43+
return NSNotFound;
44+
} else {
45+
return (NSUInteger) self.text.integerValue;
46+
}
47+
48+
}
49+
50+
@end

0 commit comments

Comments
 (0)