//
//  governmentViewController.m
//  socialSecurity
//
//  Created by 看看智能 on 2017/4/20.
//  Copyright © 2017年 黄江涛 . All rights reserved.
//

#import "governmentViewController.h"

@interface governmentViewController ()<TYAttributedLabelDelegate>

@property (nonatomic,weak) TYAttributedLabel *label1;
@property (nonatomic,weak) TYAttributedLabel *label2;
@property (nonatomic, weak) UIScrollView *scrollView;

@property(nonatomic,strong)UIButton *next;
@property(nonatomic,strong)UIButton *OFFLineGather;
@end

@implementation governmentViewController

//-(UIButton *)next
//{
//    if (!_next) {
//
//
////        [_next mas_makeConstraints:^(MASConstraintMaker *make) {
////            make.top.mas_equalTo(_label1.mas_bottom).mas_equalTo(10);
////            make.center.centerX.mas_equalTo(self.view);
////            make.size.mas_equalTo(CGSizeMake(600, 200));
////        }];
//    }
//    return _next;
//}


- (void)viewDidLoad {
    [super viewDidLoad];
   // self.title =self.titleNews;
    self.title =@"社保自助采集";
    self.view.backgroundColor =[UIColor whiteColor];
    [self addScrollView];
    [self addTextAttributedLabel1];

 
    
    
}
- (void)addScrollView
{
    UIScrollView *scrollView = [[UIScrollView alloc]initWithFrame:self.view.bounds];
//    scrollView.backgroundColor =[UIColor redColor];
    [self.view addSubview:scrollView];
    
    _scrollView = scrollView;
}

- (void)addTextAttributedLabel1
{
    TYAttributedLabel *label = [[TYAttributedLabel alloc]initWithFrame:CGRectMake(10, 0, CGRectGetWidth(self.view.frame)-20, 0)];
    label.delegate = self;
    [_scrollView addSubview:label];
    _label1 = label;
    NSString *strrrr = @"\t自助采集主要解决待遇领取人，遇到异地、偏远、生病等特殊情况，通过互联网技术，推出的便民措施.\n\t  自助采集:\n\t  1.必须是待遇领取人; \n\t  2.身份与公安部进行身份认证; \n\t  3.身份与当地社保部门核验; \n\t  4.身份核验需五个工作日，通过后发送确认短信; \n\t  5.每个账户最多可采集两人; \n\t  6.假冒他人依法追究责任人; \n\t  7.今年未采集人脸的请自助社保采集;";
    //
    

 
    
    // 分割文本到数组
    NSArray *textArray = [strrrr componentsSeparatedByString:@"\n\t"];
   
    
    NSInteger index = 0;
    for (NSString *texts in textArray) {
        NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]initWithString:texts];
        
        if (index == 0) {
            // 添加属性

//        } 
//            [attributedString addAttributeTextColor:[UIColor blackColor]];
//            [attributedString addAttributeFont:[UIFont systemFontOfSize:20
//                                                ]];
//            // 追加(添加到最后)文本
//            [label appendTextAttributedString:attributedString];
//            [label appendText:@"\n\t"];
             [label appendText:@"\n"];
            [attributedString addAttributeTextColor:kRGBColor(123, 123, 123)];
            [attributedString addAttributeFont:[UIFont systemFontOfSize:16]];

            [label appendTextAttributedString:attributedString];
            [label appendText:@"\n\n"];
        
        index++;
        }else if(index == 1){
            [attributedString addAttributeTextColor:kRGBColor(102, 102, 102)];
            [attributedString addAttributeFont: [UIFont boldSystemFontOfSize:20]];
            [label appendTextAttributedString:attributedString];
          
            index++;
        }else{
            /**
             *  添加文本段落样式
             *
             *  @param textAlignment    文本对齐样式
             *  @param linesSpacing     文本行间距
             *  @param paragraphSpacing 段落间距
             *  @param lineBreakMode    文本换行样式
             */
            [attributedString addAttributeTextColor:kRGBColor(123, 123, 123)];
              if(index == 8 ) [attributedString addAttributeFont: [UIFont boldSystemFontOfSize:15]];else    [attributedString addAttributeFont:[UIFont systemFontOfSize:16]];
        // 追加(添加到最后)文本
        [label appendText:@"\n"];
//          [label appendTextAttributedString:@"\n\n\t"];
            [label appendTextAttributedString:attributedString];

            index++;
        }
    }

    [label sizeToFit];
    

    self.next =[UIButton buttonWithType:UIButtonTypeCustom];
    _next.frame =CGRectMake(label.frame.origin.x, label.frame.size.height +124, CGRectGetWidth(self.view.frame)-20, 44);
       if (self.personPrivate == 1)  _next.center =CGPointMake(self.view.bounds.size.width/2,  label.frame.origin.y +40+label.frame.size.height); else
            
        _next.center =CGPointMake(self.view.bounds.size.width/2,  label.frame.origin.y +80+label.frame.size.height);
    _next.backgroundColor=kRGBColor(27, 132, 208);
    _next.layer.cornerRadius =7;
    if (self.personPrivate == 1)   [_next setTitle:@"下一步" forState:UIControlStateNormal];   else
        
  
    [_next setTitle:@"下一步" forState:UIControlStateNormal];
    _next.tintColor =[UIColor whiteColor];

    [_next addTarget:self action:@selector(touiButton) forControlEvents:UIControlEventTouchUpInside];
    [self.scrollView addSubview:_next];
    
    if (self.personPrivate == 1) {
    self.OFFLineGather =[UIButton buttonWithType:UIButtonTypeCustom];
    _OFFLineGather.frame =CGRectMake(label.frame.origin.x, label.frame.size.height +178, CGRectGetWidth(self.view.frame)-20, 44);
    _OFFLineGather.center =CGPointMake(self.view.bounds.size.width/2,  self.next.frame.origin.y +40+self.next.frame.size.height);
         _OFFLineGather.layer.cornerRadius =7;
    _OFFLineGather.backgroundColor=kRGBColor(27, 132, 208);
    _OFFLineGather.hidden = YES;
    
    [_OFFLineGather setTitle:@"离线采集" forState:UIControlStateNormal];
    _OFFLineGather.tintColor =[UIColor whiteColor];
    
    [_OFFLineGather addTarget:self action:@selector(touiButtons) forControlEvents:UIControlEventTouchUpInside];
    [self.scrollView addSubview:_OFFLineGather];
        
    }
    
     [_scrollView setContentSize:CGSizeMake(0, CGRectGetMaxY(label.frame) +10)];

}
-(void)touiButton{

    //huo
    //第二个
    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    socialOnceViewController *once  = [sb instantiateViewControllerWithIdentifier:@"socialOnceViewController"];
    //            socialSecurityViewController *once = [socialSecurityViewController sharedInstance];
    once.personPrivate = self.personPrivate;
    once.offLineGather =@"";
    once.hidesBottomBarWhenPushed =YES;
    [self.navigationController pushViewController:once animated:YES];
    
}

-(void)touiButtons{
    socialOffLineGatherViewController *once  = [socialOffLineGatherViewController sharedInstance];
    once.hidesBottomBarWhenPushed =YES;
    [self.navigationController pushViewController:once animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    

}



@end
