148 lines
5.3 KiB
Objective-C
148 lines
5.3 KiB
Objective-C
//
|
|
// FirstConnectWifiController.m
|
|
// Ifish
|
|
//
|
|
// Created by imac on 16/2/24.
|
|
// Copyright © 2016年 imac. All rights reserved.
|
|
//
|
|
|
|
#import "FirstConnectWifiController.h"
|
|
//#import "ConnectWifiViewController.h"
|
|
#import "SecondConnectWifiController.h"
|
|
|
|
|
|
#import "RightViewController.h"
|
|
@interface FirstConnectWifiController ()
|
|
|
|
|
|
@end
|
|
|
|
@implementation FirstConnectWifiController
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
// Do any additional setup after loading the view from its nib.
|
|
[self addTitleViewWithTitle:@"连接设备"];
|
|
self.view.backgroundColor=COLOR_MIAN;
|
|
// [_passCurrently addTarget:self action:@selector(passClick:) forControlEvents:UIControlEventTouchUpInside];
|
|
// _passCurrently.tintColor=COLOR_LABEL_TITLE;
|
|
|
|
self.navigationController.navigationBarHidden=NO;
|
|
|
|
|
|
[self initUI];
|
|
|
|
|
|
}
|
|
|
|
-(void)initUI{
|
|
|
|
CGFloat spaceH=50;
|
|
//CGFloat percent = 0.82 ;//244/205;
|
|
CGFloat imgWid =kScreenSize.width - 150;
|
|
|
|
CGFloat imgH = imgWid*0.84 ;//244/205/0.84
|
|
|
|
|
|
UIImageView *deivceimg=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"connect_tank.png"]];
|
|
deivceimg.frame = CGRectMake(kScreenSize.width/2-imgWid/2, spaceH + 64, imgWid, imgH);
|
|
[self.view addSubview:deivceimg];
|
|
|
|
|
|
UILabel *detailabel=[[UILabel alloc] init];
|
|
detailabel.text = @"请参见产品说明书上所写的方式,\n使设备处于接收状态。";
|
|
|
|
detailabel.textColor = [UIColor whiteColor];
|
|
|
|
detailabel.numberOfLines = 0;
|
|
|
|
NSMutableAttributedString * attributedString = [[NSMutableAttributedString alloc] initWithString:detailabel.text];
|
|
NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle alloc] init];
|
|
[paragraphStyle setLineSpacing:8];
|
|
[paragraphStyle setLineBreakMode:NSLineBreakByClipping];
|
|
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [detailabel.text length])];
|
|
|
|
|
|
[attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:0 green:170.0/255.0 blue:218.0/255.0 alpha:1] range:NSMakeRange(detailabel.text.length -5,4)];
|
|
|
|
[detailabel setAttributedText:attributedString];
|
|
detailabel.textAlignment = NSTextAlignmentLeft;
|
|
[detailabel sizeToFit];
|
|
CGFloat labelSizeW = [self widthForString:detailabel.text fontSize:18 andHeight:10];
|
|
CGFloat labelH= [self heightForString:detailabel.text fontSize:18 andWidth:labelSizeW];
|
|
detailabel.frame = CGRectMake(kScreenSize.width/2 - labelSizeW /2, CGRectGetMaxY(deivceimg.frame) + spaceH, labelSizeW , labelH*2);
|
|
|
|
[self.view addSubview:detailabel];
|
|
|
|
//下一步
|
|
_nextBtn=[UIButton buttonWithType:UIButtonTypeCustom];
|
|
[_nextBtn setTitle:@"下一步" forState:UIControlStateNormal];
|
|
CGFloat btnTitleW =[self widthForString:_nextBtn.titleLabel.text fontSize:20 andHeight:10];
|
|
CGFloat btnTitleH = [self heightForString:_nextBtn.titleLabel.text fontSize:20 andWidth:btnTitleW];
|
|
|
|
CGFloat spaceHY= kScreenSize.height - CGRectGetMaxY(detailabel.frame) - 20 - btnTitleH *2 ;
|
|
|
|
_nextBtn.frame = CGRectMake(10, CGRectGetMaxY(detailabel.frame) + spaceHY, kScreenSize.width - 2*10, btnTitleH *2);
|
|
[_nextBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
|
[_nextBtn addTarget:self action:@selector(nextBtn:) forControlEvents:UIControlEventTouchUpInside];
|
|
_nextBtn.backgroundColor = COLOR_LABEL_TITLE;
|
|
_nextBtn.layer.masksToBounds = YES;
|
|
_nextBtn.layer.cornerRadius = 5;
|
|
[self.view addSubview:_nextBtn];
|
|
}
|
|
|
|
-(void)nextBtn:(UIButton*)btn{
|
|
|
|
[btn setImage:[UIImage imageNamed:@"connect_nextsteep"] forState:UIControlStateSelected];
|
|
[self testwifi];
|
|
|
|
}
|
|
|
|
#pragma -mark -functions
|
|
|
|
//获取字符串的宽度
|
|
-(float) widthForString:(NSString *)value fontSize:(float)fontSize andHeight:(float)height
|
|
{
|
|
CGSize sizeToFit = [value sizeWithFont:[UIFont systemFontOfSize:fontSize] constrainedToSize:CGSizeMake(CGFLOAT_MAX, height) lineBreakMode:NSLineBreakByWordWrapping];//此处的换行类型(lineBreakMode)可根据自己的实际情况进行设置
|
|
return sizeToFit.width;
|
|
}
|
|
//获得字符串的高度
|
|
-(float) heightForString:(NSString *)value fontSize:(float)fontSize andWidth:(float)width
|
|
{
|
|
CGSize sizeToFit = [value sizeWithFont:[UIFont systemFontOfSize:fontSize] constrainedToSize:CGSizeMake(width, CGFLOAT_MAX) lineBreakMode:NSLineBreakByCharWrapping];//此处的换行类型(lineBreakMode)可根据自己的实际情况进行设置
|
|
return sizeToFit.height;
|
|
}
|
|
|
|
- (void)didReceiveMemoryWarning {
|
|
[super didReceiveMemoryWarning];
|
|
|
|
}
|
|
|
|
/**
|
|
* 检测是否wifi环境
|
|
*/
|
|
|
|
-(void)testwifi{
|
|
[[AFNetworkReachabilityManager sharedManager] startMonitoring];
|
|
[[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
|
|
NSLog(@"%ld", (long)status);
|
|
|
|
if (status==AFNetworkReachabilityStatusReachableViaWiFi) {
|
|
//wifi环境下转跳下一界面
|
|
SecondConnectWifiController*wifivc=[[SecondConnectWifiController alloc]init];
|
|
[self.navigationController pushViewController:wifivc animated:YES];
|
|
|
|
|
|
}else{
|
|
|
|
[self showTitle:@"" messsage:@"请切换到WiFi环境下绑定"];
|
|
}
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|