【发布时间】:2018-09-30 21:20:05
【问题描述】:
我有一个从屏幕底部弹出的视图,并已加载到我的应用程序委托中。我遇到的问题是我无法设置视图的 y 坐标,因此它会出现在所有屏幕尺寸的相同位置。就我而言,我试图让这个弹出视图出现在屏幕底部的标签栏上方。
这是我的代码,我将视图相对于 [[UIScreen mainScreen] bounds] 放置,但它在所有屏幕尺寸上并不一致。我怎样才能获得我需要的坐标,以便我可以将此视图垂直放置在所有屏幕上的同一位置?
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;
float y = [UIScreen mainScreen].bounds.size.height;
UIInterfaceOrientation deviceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
if (UIInterfaceOrientationIsLandscape(deviceOrientation))
{
[UIView animateWithDuration:0.5
delay:.25
options: UIViewAnimationOptionCurveEaseOut
animations:^{
self->popcontroller.frame = CGRectMake(0,y -90, screenWidth, 40);
}
completion:^(BOOL finished){
}];
}
else{
[UIView animateWithDuration:0.5
delay:.25
options: UIViewAnimationOptionCurveEaseOut
animations:^{
self->popcontroller.frame = CGRectMake(0,y -120, screenWidth, 40);
}
completion:^(BOOL finished){
}];
}
brsAppDelegate *appDelegate = (brsAppDelegate *)[[UIApplication sharedApplication] delegate];
if (![[appDelegate window].subviews containsObject:popcontroller])
{ [[appDelegate window] addSubview:popcontroller];
[popcontroller setNeedsDisplay];
}
});
}
【问题讨论】:
标签: ios xcode autolayout safearealayoutguide