我有一个绘制饼图的 UIView,我想以编程方式在 UIScrollView 中放置 3 个或 4 个图表。我怎样才能做到这一点?
我的h文件是这样的
@class PieChart;
@interface ViewController : UIViewController {
}
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
和 m 文件
- (void)viewDidLoad
{
[super viewDidLoad];
[scrollView setBackgroundColor:[UIColor blackColor]];
[scrollView setCanCancelContentTouches:NO];
scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
scrollView.clipsToBounds = YES;
scrollView.scrollEnabled = YES;
scrollView.pagingEnabled = YES;
PieChart *chart = [[PieChart alloc]initWithFrame:CGRectZero];
[chart setFrame:CGRectMake(100, 100, 200, 200)];
[scrollView addSubview:chart];
}