Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add auto new row for items. #8

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
64F0EA90A3CD2B8AE36CD1CE /* TNRadioButtonData.m in Sources */ = {isa = PBXBuildFile; fileRef = 64F0E9BD6B31F51D01EC5BC3 /* TNRadioButtonData.m */; };
86465FD41906ABD200E7FDE9 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 86465FD31906ABD200E7FDE9 /* Foundation.framework */; };
86465FD61906ABD200E7FDE9 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 86465FD51906ABD200E7FDE9 /* CoreGraphics.framework */; };
86465FD81906ABD200E7FDE9 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 86465FD71906ABD200E7FDE9 /* UIKit.framework */; };
Expand All @@ -24,12 +25,13 @@
86CEDB671906B1F1004B016A /* TNRadioButtonGroup.m in Sources */ = {isa = PBXBuildFile; fileRef = 86CEDB601906B1F1004B016A /* TNRadioButtonGroup.m */; };
86CEDB721906B4F9004B016A /* MainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 86CEDB711906B4F9004B016A /* MainViewController.m */; };
86CEDB761906B50A004B016A /* MainView.m in Sources */ = {isa = PBXBuildFile; fileRef = 86CEDB751906B50A004B016A /* MainView.m */; };
86CEDB891906FDE1004B016A /* TNRadioButtonData.m in Sources */ = {isa = PBXBuildFile; fileRef = 86CEDB881906FDE1004B016A /* TNRadioButtonData.m */; };
86CEDB8C1906FDEA004B016A /* TNCircularRadioButtonData.m in Sources */ = {isa = PBXBuildFile; fileRef = 86CEDB8B1906FDEA004B016A /* TNCircularRadioButtonData.m */; };
86CEDBA019070464004B016A /* TNRectangularRadioButtonData.m in Sources */ = {isa = PBXBuildFile; fileRef = 86CEDB9F19070464004B016A /* TNRectangularRadioButtonData.m */; };
86CEDBA31907046D004B016A /* TNRectangularRadioButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 86CEDBA21907046D004B016A /* TNRectangularRadioButton.m */; };
86CEDBA619070476004B016A /* TNImageRadioButtonData.m in Sources */ = {isa = PBXBuildFile; fileRef = 86CEDBA519070476004B016A /* TNImageRadioButtonData.m */; };
86CEDBA919070483004B016A /* TNImageRadioButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 86CEDBA819070483004B016A /* TNImageRadioButton.m */; };
C8EE178D1A88B356001A1587 /* TNFillRadioButtonData.m in Sources */ = {isa = PBXBuildFile; fileRef = C8EE178C1A88B356001A1587 /* TNFillRadioButtonData.m */; };
C8EE17901A88B3B4001A1587 /* TNFillRadioButton.m in Sources */ = {isa = PBXBuildFile; fileRef = C8EE178F1A88B3B4001A1587 /* TNFillRadioButton.m */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand All @@ -43,6 +45,8 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
64F0E706D0BDAF78C7D3ED98 /* TNRadioButtonData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TNRadioButtonData.h; path = ../../src/TNRadioButtonData.h; sourceTree = "<group>"; };
64F0E9BD6B31F51D01EC5BC3 /* TNRadioButtonData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TNRadioButtonData.m; path = ../../src/TNRadioButtonData.m; sourceTree = "<group>"; };
86465FD01906ABD200E7FDE9 /* TNRadioButtonGroupDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TNRadioButtonGroupDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
86465FD31906ABD200E7FDE9 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
86465FD51906ABD200E7FDE9 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -70,8 +74,6 @@
86CEDB711906B4F9004B016A /* MainViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainViewController.m; sourceTree = "<group>"; };
86CEDB741906B50A004B016A /* MainView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainView.h; sourceTree = "<group>"; };
86CEDB751906B50A004B016A /* MainView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainView.m; sourceTree = "<group>"; };
86CEDB871906FDE1004B016A /* TNRadioButtonData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TNRadioButtonData.h; path = ../../src/TNRadioButtonData.h; sourceTree = "<group>"; };
86CEDB881906FDE1004B016A /* TNRadioButtonData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TNRadioButtonData.m; path = ../../src/TNRadioButtonData.m; sourceTree = "<group>"; };
86CEDB8A1906FDEA004B016A /* TNCircularRadioButtonData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TNCircularRadioButtonData.h; path = ../../src/TNCircularRadioButtonData.h; sourceTree = "<group>"; };
86CEDB8B1906FDEA004B016A /* TNCircularRadioButtonData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TNCircularRadioButtonData.m; path = ../../src/TNCircularRadioButtonData.m; sourceTree = "<group>"; };
86CEDB9D19070457004B016A /* TNRadioButtonDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TNRadioButtonDelegate.h; path = ../../src/TNRadioButtonDelegate.h; sourceTree = "<group>"; };
Expand All @@ -83,6 +85,10 @@
86CEDBA519070476004B016A /* TNImageRadioButtonData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TNImageRadioButtonData.m; path = ../../src/TNImageRadioButtonData.m; sourceTree = "<group>"; };
86CEDBA719070483004B016A /* TNImageRadioButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TNImageRadioButton.h; path = ../../src/TNImageRadioButton.h; sourceTree = "<group>"; };
86CEDBA819070483004B016A /* TNImageRadioButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TNImageRadioButton.m; path = ../../src/TNImageRadioButton.m; sourceTree = "<group>"; };
C8EE178B1A88B356001A1587 /* TNFillRadioButtonData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TNFillRadioButtonData.h; path = ../../src/TNFillRadioButtonData.h; sourceTree = "<group>"; };
C8EE178C1A88B356001A1587 /* TNFillRadioButtonData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TNFillRadioButtonData.m; path = ../../src/TNFillRadioButtonData.m; sourceTree = "<group>"; };
C8EE178E1A88B3B4001A1587 /* TNFillRadioButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TNFillRadioButton.h; path = ../../src/TNFillRadioButton.h; sourceTree = "<group>"; };
C8EE178F1A88B3B4001A1587 /* TNFillRadioButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TNFillRadioButton.m; path = ../../src/TNFillRadioButton.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -109,6 +115,15 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
64F0E4A8D2D712A5B0CD80B5 /* Data */ = {
isa = PBXGroup;
children = (
64F0E706D0BDAF78C7D3ED98 /* TNRadioButtonData.h */,
64F0E9BD6B31F51D01EC5BC3 /* TNRadioButtonData.m */,
);
name = Data;
sourceTree = "<group>";
};
86465FC71906ABD200E7FDE9 = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -187,7 +202,6 @@
86BA542B1909896300E75362 /* Protocol */,
86CEDB5F1906B1F1004B016A /* TNRadioButtonGroup.h */,
86CEDB601906B1F1004B016A /* TNRadioButtonGroup.m */,
86CEDB7A1906D972004B016A /* Data */,
86CEDB6D1906B211004B016A /* Types */,
);
name = TNRadioButtonGroup;
Expand All @@ -204,9 +218,10 @@
86CEDB6D1906B211004B016A /* Types */ = {
isa = PBXGroup;
children = (
C8EE17891A88B2E2001A1587 /* Fill */,
86CEDB6F1906B22E004B016A /* Base */,
86CEDB6E1906B229004B016A /* Circular */,
86CEDB8D1906FDF5004B016A /* Rectangle */,
86CEDB8D1906FDF5004B016A /* Rectangular */,
86CEDB95190700F5004B016A /* Image */,
);
name = Types;
Expand All @@ -228,6 +243,7 @@
86CEDB5D1906B1F1004B016A /* TNRadioButton.h */,
86CEDB5E1906B1F1004B016A /* TNRadioButton.m */,
86CEDB9D19070457004B016A /* TNRadioButtonDelegate.h */,
64F0E4A8D2D712A5B0CD80B5 /* Data */,
);
name = Base;
sourceTree = "<group>";
Expand All @@ -243,15 +259,6 @@
name = "View controllers";
sourceTree = "<group>";
};
86CEDB7A1906D972004B016A /* Data */ = {
isa = PBXGroup;
children = (
86CEDB871906FDE1004B016A /* TNRadioButtonData.h */,
86CEDB881906FDE1004B016A /* TNRadioButtonData.m */,
);
name = Data;
sourceTree = "<group>";
};
86CEDB7F1906E5AA004B016A /* Data */ = {
isa = PBXGroup;
children = (
Expand All @@ -261,14 +268,14 @@
name = Data;
sourceTree = "<group>";
};
86CEDB8D1906FDF5004B016A /* Rectangle */ = {
86CEDB8D1906FDF5004B016A /* Rectangular */ = {
isa = PBXGroup;
children = (
86CEDB8E1906FDFE004B016A /* Data */,
86CEDBA11907046D004B016A /* TNRectangularRadioButton.h */,
86CEDBA21907046D004B016A /* TNRectangularRadioButton.m */,
);
name = Rectangle;
name = Rectangular;
sourceTree = "<group>";
};
86CEDB8E1906FDFE004B016A /* Data */ = {
Expand Down Expand Up @@ -299,6 +306,25 @@
name = Data;
sourceTree = "<group>";
};
C8EE17891A88B2E2001A1587 /* Fill */ = {
isa = PBXGroup;
children = (
C8EE178A1A88B2F8001A1587 /* Data */,
C8EE178E1A88B3B4001A1587 /* TNFillRadioButton.h */,
C8EE178F1A88B3B4001A1587 /* TNFillRadioButton.m */,
);
name = Fill;
sourceTree = "<group>";
};
C8EE178A1A88B2F8001A1587 /* Data */ = {
isa = PBXGroup;
children = (
C8EE178B1A88B356001A1587 /* TNFillRadioButtonData.h */,
C8EE178C1A88B356001A1587 /* TNFillRadioButtonData.m */,
);
name = Data;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -394,10 +420,11 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C8EE178D1A88B356001A1587 /* TNFillRadioButtonData.m in Sources */,
86465FE41906ABD200E7FDE9 /* AppDelegate.m in Sources */,
86CEDBA019070464004B016A /* TNRectangularRadioButtonData.m in Sources */,
86CEDB8C1906FDEA004B016A /* TNCircularRadioButtonData.m in Sources */,
86CEDB891906FDE1004B016A /* TNRadioButtonData.m in Sources */,
C8EE17901A88B3B4001A1587 /* TNFillRadioButton.m in Sources */,
86465FE01906ABD200E7FDE9 /* main.m in Sources */,
86CEDB721906B4F9004B016A /* MainViewController.m in Sources */,
86CEDBA31907046D004B016A /* TNRectangularRadioButton.m in Sources */,
Expand All @@ -407,6 +434,7 @@
86CEDB651906B1F1004B016A /* TNCircularRadioButton.m in Sources */,
86CEDB661906B1F1004B016A /* TNRadioButton.m in Sources */,
86CEDB671906B1F1004B016A /* TNRadioButtonGroup.m in Sources */,
64F0EA90A3CD2B8AE36CD1CE /* TNRadioButtonData.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -526,7 +554,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "TNRadioButtonGroupDemo/TNRadioButtonGroupDemo-Prefix.pch";
INFOPLIST_FILE = "TNRadioButtonGroupDemo/TNRadioButtonGroupDemo-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 6.1;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
Expand All @@ -540,7 +568,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "TNRadioButtonGroupDemo/TNRadioButtonGroupDemo-Prefix.pch";
INFOPLIST_FILE = "TNRadioButtonGroupDemo/TNRadioButtonGroupDemo-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 6.1;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
}
],
"info" : {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
},
{
"idiom" : "iphone",
"scale" : "1x"
Expand All @@ -18,6 +26,10 @@
"filename" : "[email protected]",
"subtype" : "retina4",
"scale" : "2x"
},
{
"idiom" : "iphone",
"scale" : "3x"
}
],
"info" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
"idiom" : "universal",
"scale" : "2x",
"filename" : "[email protected]"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
"idiom" : "universal",
"scale" : "2x",
"filename" : "[email protected]"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
Expand Down
1 change: 1 addition & 0 deletions TNRadioButtonGroupDemo/TNRadioButtonGroupDemo/MainView.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
@property (nonatomic, strong) TNRadioButtonGroup *sexGroup;
@property (nonatomic, strong) TNRadioButtonGroup *hobbiesGroup;
@property (nonatomic, strong) TNRadioButtonGroup *temperatureGroup;
@property (nonatomic, strong) TNRadioButtonGroup *noGroup;

@end
57 changes: 55 additions & 2 deletions TNRadioButtonGroupDemo/TNRadioButtonGroupDemo/MainView.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ - (id)initWithFrame:(CGRect)frame {
[self createHorizontalList];
[self createVerticalList];
[self createHorizontalListWithImage];
[self createHorizontalListWithBg];
}

return self;
Expand Down Expand Up @@ -51,11 +52,23 @@ - (void)createHorizontalList {
alienData.circleColor = [UIColor blackColor];
alienData.borderRadius = 12;
alienData.circleRadius = 5;

TNCircularRadioButtonData *noData = [TNCircularRadioButtonData new];
noData.labelText = @"noData";
noData.identifier = @"noData";
noData.selected = NO;
noData.borderColor = [UIColor blackColor];
noData.circleColor = [UIColor blackColor];
noData.borderRadius = 12;
noData.circleRadius = 5;

self.sexGroup = [[TNRadioButtonGroup alloc] initWithRadioButtonData:@[maleData, femaleData, alienData] layout:TNRadioButtonGroupLayoutHorizontal];
self.sexGroup = [[TNRadioButtonGroup alloc] initWithRadioButtonData:@[maleData, femaleData, alienData, noData] layout:TNRadioButtonGroupLayoutHorizontal];
self.sexGroup.identifier = @"Sex group";
self.sexGroup.marginBetweenItems = 15;
self.sexGroup.itemsInsets = UIEdgeInsetsMake(15, 15, 0, 0);
self.sexGroup.rowItemCount = 2;
[self.sexGroup create];
self.sexGroup.position = CGPointMake(25, 175);
self.sexGroup.position = CGPointMake(0, 145);
[self addSubview:self.sexGroup];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sexGroupUpdated:) name:SELECTED_RADIO_BUTTON_CHANGED object:self.sexGroup];
Expand Down Expand Up @@ -137,6 +150,41 @@ - (void)createHorizontalListWithImage {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(temperatureGroupUpdated:) name:SELECTED_RADIO_BUTTON_CHANGED object:self.temperatureGroup];
}

- (void)createHorizontalListWithBg {
TNFillRadioButtonData *firstData = [TNFillRadioButtonData new];
firstData.labelText = @"First";
firstData.identifier = @"First";
firstData.selected = NO;
firstData.labelBgNormalColor = [UIColor grayColor];
firstData.labelBgSelectedColor = [UIColor redColor];
firstData.labelMarginLeft = -1;
firstData.labelWidth = 60.0f;
firstData.labelHeight = 30.0f;
firstData.labelBorderWidth = 1.0;
firstData.labelBorderColor = [UIColor brownColor].CGColor;
firstData.labelBorderCornerRadius = 5.0;

TNFillRadioButtonData *secondData = [TNFillRadioButtonData new];
secondData.labelText = @"Second";
secondData.identifier = @"Second";
secondData.selected = NO;
secondData.labelBgNormalColor = [UIColor grayColor];
secondData.labelBgSelectedColor = [UIColor redColor];
secondData.labelMarginLeft = -1;
secondData.labelWidth = 60.0f;
secondData.labelHeight = 30.0f;


self.noGroup = [[TNRadioButtonGroup alloc] initWithRadioButtonData:@[firstData, secondData] layout:TNRadioButtonGroupLayoutHorizontal];
self.noGroup.identifier = @"No Group";
[self.noGroup create];
self.noGroup.position = CGPointMake(0, 500);

[self addSubview:self.noGroup];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(noGroupUpdated:) name:SELECTED_RADIO_BUTTON_CHANGED object:self.noGroup];
}

- (void)sexGroupUpdated:(NSNotification *)notification {
NSLog(@"[MainView] Sex group updated to %@", self.sexGroup.selectedRadioButton.data.identifier);
}
Expand All @@ -149,10 +197,15 @@ - (void)temperatureGroupUpdated:(NSNotification *)notification {
NSLog(@"[MainView] Temperature group updated to %@", self.temperatureGroup.selectedRadioButton.data.identifier);
}

- (void)noGroupUpdated:(NSNotification *)notification {
NSLog(@"[MainView] No. group updated to %@", self.noGroup.selectedRadioButton.data.identifier);
}

- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self name:SELECTED_RADIO_BUTTON_CHANGED object:self.sexGroup];
[[NSNotificationCenter defaultCenter] removeObserver:self name:SELECTED_RADIO_BUTTON_CHANGED object:self.hobbiesGroup];
[[NSNotificationCenter defaultCenter] removeObserver:self name:SELECTED_RADIO_BUTTON_CHANGED object:self.temperatureGroup];
[[NSNotificationCenter defaultCenter] removeObserver:self name:SELECTED_RADIO_BUTTON_CHANGED object:self.noGroup];
}

@end
17 changes: 17 additions & 0 deletions src/TNFillRadioButton.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// TNFillRadioButton.h
// TNRadioButtonGroupDemo
//
// Created by olunx on 15/2/9.
// Copyright (c) 2015年 Frederik Jacques. All rights reserved.
//

#import "TNRadioButton.h"

@interface TNFillRadioButton : TNRadioButton

@property (nonatomic, strong) TNFillRadioButtonData *data;

- (instancetype)initWithData:(TNFillRadioButtonData *)data;

@end
Loading