2015-02-06 4 views
0

어떻게하면 새로 고침 컨트롤의 높이를 설정할 수 있습니까? 새로 고침 제어를 위해 맞춤로드 아이콘을 만들려면 http://www.jackrabbitmobile.com/design/ios-custom-pull-to-refresh-control/ 을 사용하고 있습니다. 내가 새로 고침 컨트롤의 높이 즉 탐색 바 끝과 tableview가 시작되는 곳 사이의 공간을 늘려서 이미지 위와 아래에 공간이 생기게하고 싶습니다. 내가iOS 새로 고침 컨트롤 높이

self.refreshControl = [[UIRefreshControl alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 200)]; 

를 사용하여 시도

- (void)setupRefreshControl 
{ 
// Programmatically inserting a UIRefreshControl 
self.refreshControl = [[UIRefreshControl alloc] init]; 

// Setup the loading view, which will hold the moving graphics 
self.refreshLoadingView = [[UIView alloc] initWithFrame:self.refreshControl.bounds]; 
self.refreshLoadingView.backgroundColor = [UIColor clearColor]; 

// Setup the color view, which will display the rainbowed background 
self.refreshColorView = [[UIView alloc] initWithFrame:self.refreshControl.bounds]; 
self.refreshColorView.backgroundColor = [UIColor clearColor]; 
self.refreshColorView.alpha = 0.30; 

// Create the graphic image views 
self.compass_background = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"compass_background.png"]]; 
self.compass_spinner = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"compass_spinner.png"]]; 

// Add the graphics to the loading view 
[self.refreshLoadingView addSubview:self.compass_background]; 
[self.refreshLoadingView addSubview:self.compass_spinner]; 

// Clip so the graphics don't stick out 
self.refreshLoadingView.clipsToBounds = YES; 

// Hide the original spinner icon 
self.refreshControl.tintColor = [UIColor clearColor]; 

// Add the loading and colors views to our refresh control 
[self.refreshControl addSubview:self.refreshColorView]; 
[self.refreshControl addSubview:self.refreshLoadingView]; 

// Initalize flags 
self.isRefreshIconsOverlap = NO; 
self.isRefreshAnimating = NO; 

// When activated, invoke our refresh function 
[self.refreshControl addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged]; 
} 

그러나 그것은 작동하지 않는 것 : 아래는 내가 코드를 사용한다.

답변

0

을 배치 할 수 있습니다 :

새로 고침 제어를 소유 UITableViewController 객체가 해당 컨트롤의 프레임 사각형을 설정하기위한 책임이 있습니다. 따라서 뷰 계층 구조에서 새로 고침 컨트롤의 크기 나 위치를 직접 관리 할 필요가 없습니다.

UITableViewController 개의 메서드를 사용하거나 레이아웃 제약을 추가하는 등의 해킹을 시도 할 수는 있지만 가치가 없을 것입니다.

대신 사용자가 원하는대로하려면 CBStoreHouseRefreshControl과 같은 사용자 지정 라이브러리를 사용합니다.

0

새로 고침 컨트롤 내부에 더 많은 공간이있는 것처럼 들립니다. 언급 된 방식대로 공백을 변경하려면 UI 요소 (필자의 예에서는 나침반 + 회 전자)의 좌표를 변경하거나 이미지에 패딩을 추가 할 수 있습니다.

scrollViewDidScroll 메서드는 UI 좌표를 설정하는 곳입니다. 이 메소드는 테이블이 당겨질 때 호출되며, 더 많이 당길수록 더 많은 요소가 이동됩니다.

JRTableViewController.m의 55 번째 줄과 56 번째 줄은 업데이트 된 프레임이 요소에 적용되고 UI가 실제로 이동하는 곳입니다. 새로 고침 컨트롤 안에 더 많은 공간이 필요하면 프레임을 변경하여 요소의 위치를 ​​변경할 수 있습니다.

질문에 대한 답변이 되었기를 바랍니다. 그렇지 않다면 달성하고자하는 효과에 대해 자세히 알려주세요. 그리고 우리의 기사가 도움이되기를 바랍니다!

--Anthony

1

UIRefreshControl 크기 자체가 파단의에 맞게) = 우리가 만든 알려주십시오. 따라서 크기를 변경하려면 컨트롤 자체를 가져 오려면 크기를 변경해야합니다.

override func layoutSubviews() { 
    for view in subviews { 
     view.frame = CGRectMake(1, 2, 3, 4) // or whatever size you want 
    } 

    super.layoutSubviews() 
} 
: 당신이 뭔가를 할 수 있습니다 UIRefreshControl 서브 클래스에서