diff --git a/UUChart/UUChart.h b/UUChart/UUChart.h index dd1badf..c39aae8 100755 --- a/UUChart/UUChart.h +++ b/UUChart/UUChart.h @@ -19,6 +19,7 @@ typedef NS_ENUM(NSInteger, UUChartStyle){ }; @class UUChart; + @protocol UUChartDataSource @required @@ -49,9 +50,11 @@ typedef NS_ENUM(NSInteger, UUChartStyle){ @interface UUChart : UIView +@property (assign, nonatomic) id dataSource; + @property (nonatomic) UUChartStyle chartStyle; -- (id)initwithUUChartDataFrame:(CGRect)rect withSource:(id)dataSource withStyle:(UUChartStyle)style; +- (id)initWithFrame:(CGRect)frame dataSource:(id)dataSource style:(UUChartStyle)style; - (void)showInView:(UIView *)view; diff --git a/UUChart/UUChart.m b/UUChart/UUChart.m index 50f9fe5..64a3876 100755 --- a/UUChart/UUChart.m +++ b/UUChart/UUChart.m @@ -14,16 +14,14 @@ @interface UUChart () @property (strong, nonatomic) UUBarChart * barChart; -@property (assign, nonatomic) id dataSource; - @end @implementation UUChart --(id)initwithUUChartDataFrame:(CGRect)rect withSource:(id)dataSource withStyle:(UUChartStyle)style{ +- (id)initWithFrame:(CGRect)frame dataSource:(id)dataSource style:(UUChartStyle)style { self.dataSource = dataSource; self.chartStyle = style; - return [self initWithFrame:rect]; + return [self initWithFrame:frame]; } - (id)initWithFrame:(CGRect)frame diff --git a/UUChartView.xcodeproj/project.pbxproj b/UUChartView.xcodeproj/project.pbxproj index 6492df2..148a533 100644 --- a/UUChartView.xcodeproj/project.pbxproj +++ b/UUChartView.xcodeproj/project.pbxproj @@ -22,6 +22,8 @@ B7A189881A58DAC600579497 /* RootViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = B7A189861A58DAC600579497 /* RootViewController.xib */; }; B7A1898E1A58DDBB00579497 /* TableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = B7A1898C1A58DDBB00579497 /* TableViewCell.m */; }; B7A1898F1A58DDBB00579497 /* TableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = B7A1898D1A58DDBB00579497 /* TableViewCell.xib */; }; + F03B79E41C4E6001005E0EBD /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F03B79E21C4E6001005E0EBD /* ViewController.swift */; }; + F03B79E51C4E6001005E0EBD /* ViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F03B79E31C4E6001005E0EBD /* ViewController.xib */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -63,6 +65,9 @@ B7A1898B1A58DDBB00579497 /* TableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TableViewCell.h; sourceTree = ""; }; B7A1898C1A58DDBB00579497 /* TableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TableViewCell.m; sourceTree = ""; }; B7A1898D1A58DDBB00579497 /* TableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = TableViewCell.xib; sourceTree = ""; }; + F03B79DF1C4E5F58005E0EBD /* UUChartView-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UUChartView-Bridging-Header.h"; sourceTree = ""; }; + F03B79E21C4E6001005E0EBD /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + F03B79E31C4E6001005E0EBD /* ViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ViewController.xib; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -116,6 +121,9 @@ B7A189581A58D9A200579497 /* Images.xcassets */, B7A1895A1A58D9A200579497 /* LaunchScreen.xib */, B7A1894B1A58D9A200579497 /* Supporting Files */, + F03B79DF1C4E5F58005E0EBD /* UUChartView-Bridging-Header.h */, + F03B79E21C4E6001005E0EBD /* ViewController.swift */, + F03B79E31C4E6001005E0EBD /* ViewController.xib */, ); path = UUChartView; sourceTree = ""; @@ -245,6 +253,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + F03B79E51C4E6001005E0EBD /* ViewController.xib in Resources */, B7A1895C1A58D9A200579497 /* LaunchScreen.xib in Resources */, B7A1898F1A58DDBB00579497 /* TableViewCell.xib in Resources */, B7A189881A58DAC600579497 /* RootViewController.xib in Resources */, @@ -271,6 +280,7 @@ B7A189511A58D9A200579497 /* AppDelegate.m in Sources */, B7A1898E1A58DDBB00579497 /* TableViewCell.m in Sources */, B7A189871A58DAC600579497 /* RootViewController.m in Sources */, + F03B79E41C4E6001005E0EBD /* ViewController.swift in Sources */, B7A189831A58DA8500579497 /* UULineChart.m in Sources */, B7A1897F1A58DA8500579497 /* UUBarChart.m in Sources */, B7A189821A58DA8500579497 /* UUColor.m in Sources */, @@ -390,11 +400,14 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; INFOPLIST_FILE = UUChartView/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 6.0; + IPHONEOS_DEPLOYMENT_TARGET = 7.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.uyiuyao.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "UUChartView/UUChartView-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; }; name = Debug; }; @@ -402,11 +415,13 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; INFOPLIST_FILE = UUChartView/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 6.0; + IPHONEOS_DEPLOYMENT_TARGET = 7.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.uyiuyao.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "UUChartView/UUChartView-Bridging-Header.h"; }; name = Release; }; diff --git a/UUChartView.xcodeproj/project.xcworkspace/xcuserdata/xcodeyang.xcuserdatad/UserInterfaceState.xcuserstate b/UUChartView.xcodeproj/project.xcworkspace/xcuserdata/xcodeyang.xcuserdatad/UserInterfaceState.xcuserstate index dae8693..a3c6502 100644 Binary files a/UUChartView.xcodeproj/project.xcworkspace/xcuserdata/xcodeyang.xcuserdatad/UserInterfaceState.xcuserstate and b/UUChartView.xcodeproj/project.xcworkspace/xcuserdata/xcodeyang.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/UUChartView.xcodeproj/xcuserdata/xcodeyang.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/UUChartView.xcodeproj/xcuserdata/xcodeyang.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index fe2b454..a18d79f 100644 --- a/UUChartView.xcodeproj/xcuserdata/xcodeyang.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/UUChartView.xcodeproj/xcuserdata/xcodeyang.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -2,4 +2,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/UUChartView/RootViewController.m b/UUChartView/RootViewController.m index 1c682f0..c219111 100644 --- a/UUChartView/RootViewController.m +++ b/UUChartView/RootViewController.m @@ -8,6 +8,7 @@ #import "RootViewController.h" #import "TableViewCell.h" +#import "UUChartView-swift.h" @interface RootViewController () @@ -60,6 +61,12 @@ - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger return label; } +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath +{ + ViewController *vc = [ViewController new]; + [self.navigationController pushViewController:vc animated:YES]; +} + - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. diff --git a/UUChartView/RootViewController.xib b/UUChartView/RootViewController.xib index 166a1ad..8e25564 100644 --- a/UUChartView/RootViewController.xib +++ b/UUChartView/RootViewController.xib @@ -1,5 +1,5 @@ - + @@ -16,7 +16,7 @@ - + diff --git a/UUChartView/TableViewCell.m b/UUChartView/TableViewCell.m index 7775154..d822a24 100644 --- a/UUChartView/TableViewCell.m +++ b/UUChartView/TableViewCell.m @@ -27,9 +27,9 @@ - (void)configUI:(NSIndexPath *)indexPath path = indexPath; - chartView = [[UUChart alloc]initwithUUChartDataFrame:CGRectMake(10, 10, [UIScreen mainScreen].bounds.size.width-20, 150) - withSource:self - withStyle:indexPath.section==1?UUChartStyleBar:UUChartStyleLine]; + chartView = [[UUChart alloc]initWithFrame:CGRectMake(10, 10, [UIScreen mainScreen].bounds.size.width-20, 150) + dataSource:self + style:indexPath.section==1?UUChartStyleBar:UUChartStyleLine]; [chartView showInView:self.contentView]; } diff --git a/UUChartView/UUChartView-Bridging-Header.h b/UUChartView/UUChartView-Bridging-Header.h new file mode 100644 index 0000000..5775e53 --- /dev/null +++ b/UUChartView/UUChartView-Bridging-Header.h @@ -0,0 +1,5 @@ +// +// Use this file to import your target's public headers that you would like to expose to Swift. +// + +#import "UUChart.h" diff --git a/UUChartView/ViewController.swift b/UUChartView/ViewController.swift new file mode 100644 index 0000000..140ecf4 --- /dev/null +++ b/UUChartView/ViewController.swift @@ -0,0 +1,62 @@ +// +// ViewController.swift +// UUChartView +// +// Created by Daniel on 1/19/16. +// Copyright © 2016 uyiuyao. All rights reserved. +// + +import UIKit + +class ViewController: UIViewController,UUChartDataSource { + + var chart:UUChart! + + override func viewDidLoad() { + super.viewDidLoad() + + chart = UUChart(frame: CGRectMake(0, 150, 375, 200), dataSource: self, style: UUChartStyle.Line) + chart.showInView(view) + } + + func chartConfigAxisXLabel(chart: UUChart!) -> [AnyObject]! { + return ["星期一","星期二","星期三","星期四","星期五","星期六","星期日"] + } + + func chartConfigAxisYValue(chart: UUChart!) -> [AnyObject]! { + return [["22","44","15","40","42","23","34"]] + } + + func chart(chart: UUChart!, showHorizonLineAtIndex index: Int) -> Bool { + return true + } + + func chart(chart: UUChart!, showMaxMinAtIndex index: Int) -> Bool { + return true + } + + func chartConfigColors(chart: UUChart!) -> [AnyObject]! { + return [UIColor.redColor()] + } + + func chartRange(chart: UUChart!) -> CGRange { + return CGRangeMake(60, 10) + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + + /* + // MARK: - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { + // Get the new view controller using segue.destinationViewController. + // Pass the selected object to the new view controller. + } + */ + +} diff --git a/UUChartView/ViewController.xib b/UUChartView/ViewController.xib new file mode 100644 index 0000000..3828d0c --- /dev/null +++ b/UUChartView/ViewController.xib @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + +