2014-09-04 34 views
3

我正在使用UITableView和UIRefreshControl開發iOS應用程序。更改UIRefreshControl指標在iOS應用程序中的初始位置

我想將UIRefreshControl指標的初始位置從默認改爲50px。我寫下下面的代碼。

但是,初始位置沒有改變。它仍然保持原來的狀態。

你能告訴我如何解決這個問題嗎?

CGFloat customRefreshControlHeight = 50.0f; 
CGFloat customRefreshControlWidth = 320.0f; 
CGRect customRefreshControlFrame = CGRectMake(0.0f, 
               customRefreshControlHeight, 
               customRefreshControlWidth, 
               customRefreshControlHeight); 
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] initWithFrame:customRefreshControlFrame]; 
refreshControl.tintColor = [UIColor blackColor]; 
[refreshControl addTarget:self action:@selector(onRefresh:) forControlEvents:UIControlEventValueChanged]; 
[self.tableView addSubview:refreshControl]; 

回答

0

只是簡單的(SWIFT)

override func viewDidLayoutSubviews() { 
     super.viewDidLayoutSubviews() 
     refreshController.frame = CGRectMake(refreshController.bounds.origin.x, 
               50.0, 
               refreshController.bounds.size.width, 
               refreshController.bounds.size.height); 
     refreshController.superview?.sendSubviewToBack(refreshController) // for fix overlap tableview 
    } 
相關問題