简体   繁体   English

UIView没有填充它的框架

[英]UIView not filling its frame

I'm trying to use this XYPieChart here, the demo works great and it looks beautiful. 我想在这里使用这个XYPieChart ,这个演示效果很好,看起来很漂亮。 Problem is, whenever I try to recreate it on a Storyboard, the chart appears incredibly small and I can't seem to resize it. 问题是,每当我尝试在故事板上重新创建它时,图表看起来非常小,我似乎无法调整它的大小。 I've played around with all the settings and set the frame of the property and nothing seems to work. 我玩过所有的设置,并设置了属性的框架,似乎没有任何作用。 I've tried resizing it to the entire screen with: 我已尝试将其调整到整个屏幕:

[self.pieChart setFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];

Still the same result except the frame stretches across the screen and everything is grey. 除了框架之外,仍然有相同的结果在屏幕上延伸,一切都是灰色的。 Anyone, this is how it's coming out, the grey is the frame and the XYPieChart loads in the center: 任何人,这就是它的出现方式,灰色是框架,XYPieChart在中心加载:

I'm still fairly new and I've been searching how to remedy this but I can't formulate a good enough search query that makes sense. 我仍然相当新,我一直在寻找如何解决这个问题,但我不能制定一个足够有用的搜索查询。

It looks like you haven't set the pieRadius property on the chart. 看起来您没有在图表上设置pieRadius属性。

If you change this it should make the pie bigger. 如果你改变它,它应该使馅饼更大。

The problem is due to AutoLayout. 问题是由于AutoLayout。 If you want to keep using AutoLayout in your project, you can simply change your viewDidAppear this way: 如果您想在项目中继续使用AutoLayout,您可以通过以下方式更改viewDidAppear:

- (void)viewDidAppear:(BOOL)animated {

    self.pieChart.pieRadius = MIN(self.pieChart.frame.size.width/2, self.pieChart.frame.size.height/2) - 10;
    self.pieChart.self.pieCenter = CGPointMake(self.pieChart.frame.size.width/2, self.pieChart.frame.size.height/2);
    self.pieChart.labelRadius = self.pieChart.pieRadius/2;
    self.pieChart.labelFont = [UIFont boldSystemFontOfSize:MAX((int)self.pieChart.pieRadius/10, 5)];


    [self.pieChart reloadData];

}

At the moment viewDidAppear will be called, your pieChart frame will be already updated with sizes provided by AutoLayout. 在调用viewDidAppear时,您的pieChart框架将已使用AutoLayout提供的大小进行更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM