2014-09-24 7 views
1

나는 TableView의 셀에 그래디언트 효과를 적용하는 방법에 대한 많은 자습서를 보았지만 사용자가 기본 색상을 선택한 다음 모든 셀에 걸쳐 그래디언트 효과를 만드는 것이 목표였습니다. 테이블의. 이 유사 : 사람이 이것을 달성하는 방법에 대한 아이디어가있는 경우iOS TableView Gradient Effect

http://realmacsoftware.com/clear/

하는, 즉 좋은 것입니다!

답변

4

cellForRowAtIndexPath에서 각 색상을 계산하면됩니다.

일부 위조 된 코드로 아이디어를 얻을 수 있습니다.

- (UIColor *)colorForRow:(NSInteger)row withTotalRows:(NSInteger)totalRows { 
// code to calculate the colors, you can use total rows to insure the end color. 
// You will want to calculate the percentage of each color for your gradient. 

    return color; 
} 

- (UITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    // Get your cell first 

    NSInteger totalRows = [self numberOfRowsInSection:indexPath.section]; 
    cell.contentView.backgroundColor = [self colorForRow:indexPath.row withTotalRows:totalRows]; 

} 
+0

감사합니다. – user3744562