QAView表示两个UIScrollViews
:_questionsScroller
和_answersScroller
,分别用两个数组:_questions
和_answers
填充。当点击问题后,它变得活跃,并准备好与答案连接。当您需要可视化数组的元素之间的依赖关系时,请使用此库。
只需将QAView/QAView
文件夹拖放到您的项目中。
设置很简单
_qaView = [[QAView alloc] initWithFrame:self.view.frame
questions:@[@"Frank",
@"Jason"]
answers:@[@"Anna",
@"Maria",
@"Jessica"]];
您可以设置高亮颜色
_qaView.colors = @[[UIColor greenColor], [UIColor purpleColor]];
如果没有设置,高亮颜色将自动生成,色调步长为(360./[questions count])/360.
您可以设置非活动颜色
_qaView.inactiveColor = [UIColor redColor];
默认颜色为灰色,亮度为0.89
设置逻辑模式
_qaView.canUseOneAnswerToSeveralQuestions = NO; //Defaults to YES
_qaView.canUseSeveralAnswersToOneQuestion = NO; //Defaults to YES
您可以设置为QAView任何您喜欢的代理
_qaView.delegate = self;
为此,采用<QAViewDelegate>
协议。它有以下@optional
方法
- (void)didRecieveTapInAnswerView:(QAItemView *)view;
- (void)didRecieveTapInQuestionView:(QAItemView *)view;
- (void)answersScrollerDidScroll:(QAScrollView *)scrollView;
- (void)questionsScrollerDidScroll:(QAScrollView *)scrollView;
- (QAItemView *)itemViewForAnswerAtIndex:(NSUInteger)index; //cutom cell set up
- (QAItemView *)itemViewForQuestionAtIndex:(NSUInteger)index; //custom cell set up
- (NSUInteger)numberOfAnswers;
- (NSUInteger)numberOfQuestions;
以下单元格(QAItemView
)属性是为自定义设置而设计的
@property (strong, nonatomic) UIColor* highlightColor;
@property (strong, nonatomic) UIColor* inactiveColor;;
@property (strong, nonatomic) UILabel* textLabel;
@property (nonatomic) CFTimeInterval connectingAnimationDuration;
@property (nonatomic) CGFloat connectingLineWidth;
@property (nonatomic) BOOL useGradients;
@property (nonatomic) BOOL useCirclesOnLineConnectionPoints;
@property (nonatomic) BOOL useCurvesInConnection;
在初始化itemViewForAnswerAtIndex: / itemViewForQuestionAtIndex:中的QAItemView时对其进行编辑。
重要
在通过初始化[[QAItemView alloc] init]在itemViewForAnswerAtIndex: / itemViewForQuestionAtIndex:中设置或检索其框架时,不要设置或检索框架,因为框架将在调用此方法后自动设置。
为MANUAL FRAME SET UP,请使用以下初始化程序
- (id)initWithFrame:(CGRect)frame text:(NSString*)text
index:(NSInteger)index
totalQuestions:(NSInteger)totalQuestions
inactiveColor:(UIColor*)inactiveColor
activeColor:(UIColor*)activeColor
asQuestion:(BOOL)asQuestion
有关用于自动单元格框架计算的公式的详细信息,请查看示例项目。
调用QAView
的方法
- (NSIndexSet*)connectedQuestionsIndexesForAnswerAtIndex:(NSUInteger)index;
- (NSIndexSet*)connectedAnswersIndexesForQuestionAtIndex:(NSUInteger)index;
Nikita Borisov https://twitter.com/nikita_kerd
QAView在MIT许可下可用。有关更多信息,请参阅LICENSE文件。