在肖像和风景中设置UIView位置

时间:2014-04-18 14:18:06

标签: ios objective-c uiview

我创建了一个加载器视图。我已使用以下代码设置指标的位置:

    loadingView = [[UIView alloc]initWithFrame:CGRectMake(455, 225, 80, 80)]

如何为肖像模式设置不同的位置? 感谢

1 个答案:

答案 0 :(得分:1)

if([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait)
{
//portrait
loadingView = [[UIView alloc]initWithFrame:CGRectMake(225, 455, 80, 80)];//any position you want
}
else
{
//landscape
loadingView = [[UIView alloc]initWithFrame:CGRectMake(455, 225, 80, 80)];//any position you want
}