[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/flattech/Coding-iOS/master/Coding_iOS/Views/TopicListView.m [Back]  [Original]

//
//  TopicListView.m
//  Coding_iOS
//
//  Created by  on 15/4/19.
//  Copyright (c) 2015 Coding. All rights reserved.
//

#import "TopicListView.h"
#import "TopicListButton.h"

@interface TopicListView ()
{
    UIScrollView *_baseView;
    UIButton *_baseBtn;
    NSInteger _count;
    NSInteger _index;
}

@property (nonatomic , copy) TopicListViewBlock block;
@property (nonatomic , copy) TopicListViewHideBlock hideBlock;

@end

@implementation TopicListView

- (id)initWithFrame:(CGRect)frame
             titles:(NSArray *)titles
            numbers:(NSArray *)numbers
       defaultIndex:(NSInteger)index
      selectedBlock:(TopicListViewBlock)selectedHandle
          hideBlock:(TopicListViewHideBlock)hideHandle
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.4];
        self.block = selectedHandle;
        self.hideBlock = hideHandle;
        self.clipsToBounds = YES;
        
        _baseBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, self.frame.size.height)];
        _baseBtn.backgroundColor = [UIColor clearColor];
        [_baseBtn addTarget:self action:@selector(baseBtnClick) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_baseBtn];
        
        _index = index;
        _count = titles.count;
        CGFloat h = _count * kMySegmentControl_Height;
        CGFloat sH = h;
        if (h + kMySegmentControl_Height > self.frame.size.height) {
            sH = self.frame.size.height - kMySegmentControl_Height;
        }
        _baseView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, -sH, kScreen_Width, sH)];
        [self addSubview:_baseView];
        _baseView.contentSize = CGSizeMake(kScreen_Width, h);
        _baseView.bounces = FALSE;

        UIView *btnView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, h)];
        btnView.backgroundColor = [UIColor whiteColor];
        [_baseView addSubview:btnView];
        
        for (int i=0; i self.frame.size.height) {
            sH = self.frame.size.height - kMySegmentControl_Height;
        }
        _baseView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, -sH, kScreen_Width, sH)];
        [self addSubview:_baseView];
        _baseView.contentSize = CGSizeMake(kScreen_Width, h);
        _baseView.bounces = FALSE;
        
        UIView *btnView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, h)];
        btnView.backgroundColor = [UIColor whiteColor];
        [_baseView addSubview:btnView];
        
        for (int i=0; i

Web Proxy Viewer  |  New URL  |  Original Page