解决ios7页面元素上移20像素

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    _textView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 200, 100)];
    _textView.backgroundColor = [UIColor greenColor];
    [self.view addSubview:_textView];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    
}

- (void)viewDidLayoutSubviews
{
    [super viewDidLayoutSubviews];
    self.textView.frame = CGRectMake(0,
                                     [self topOfViewOffset],
                                     self.textView.frame.size.width,
                                     self.textView.frame.size.height);
}
- (CGFloat)topOfViewOffset
{
    CGFloat top = 0;
    if ([self respondsToSelector:@selector(topLayoutGuide)])
    {
        top = self.topLayoutGuide.length;
    }
    return top;
}

 

posted @ 2013-11-21 21:28  爱笑的雷小豆  阅读(260)  评论(0)    收藏  举报