开发者社区> 问答> 正文

怪异的自动收费中心问题

这件事一直困扰着我。

基本上,当我使用布局锚手动定义autolayout约束,并在弹出器中使用视图控制器时,中心位于错误的位置。它似乎围绕着从弹出箭头的左边到左边和右边边缘的边界,这不是弹射区域的中心。

这似乎与其他UIViewController表示方法(如UIModalPresentationFormSheet)工作得很好。

有什么想法吗?我怎样才能以一种对布局友好的方式解决这个问题,而不需要特殊的边框?

PS。如果将布局固定在父视图的中心,则会发生完全相同的情况。

-(void)loadView {

UIView *view = [[UIView alloc] init];

[![enter image description here][1]][1] [view setBackgroundColor:[UIColor greenColor]]; [view setTranslatesAutoresizingMaskIntoConstraints:NO]; self.view = view;

UIView *parentView = [[UIView alloc] init];

[parentView setTranslatesAutoresizingMaskIntoConstraints:NO];
[parentView setBackgroundColor:[self colorForTag:i]];
[self.view addSubview:parentView];
// constrain parent view.
[parentView.topAnchor constraintEqualToAnchor:self.view.topAnchor constant:10.0].active = YES;
[parentView.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor constant:-10.0].active = YES;

}

展开
收起
游客5akardh5cojhg 2019-12-05 13:23:58 373 0
0 条回答
写回答
取消 提交回答
问答地址:
问答排行榜
最热
最新

相关电子书

更多
k8s自动伸缩那些事资料下载 立即下载
“移”码平川-移动端高可用性体系 立即下载
“移”码平川—移动端高可用性体系 立即下载