QAView 0.1.1

QAView 0.1.1

测试已测试
Lang语言 Obj-CObjective C
许可 MIT
发布上次发布2016年2月

belakva维护。




QAView 0.1.1

QAView表示两个UIScrollViews_questionsScroller_answersScroller,分别用两个数组:_questions_answers填充。当点击问题后,它变得活跃,并准备好与答案连接。当您需要可视化数组的元素之间的依赖关系时,请使用此库。

要求

  • iOS 7 - 如果手动安装
  • iOS 8 - 如果使用CocoaPods

安装

手动

只需将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文件。