//强制横屏
AppDelegate *appdelegate=(AppDelegate *)[UIApplication sharedApplication].delegate;
appdelegate.allowRotation=YES;
//2.修改textfield的placeholder字体大小
if (IS_IPHONE_5) {
NSString *holderText = @"请输入验证码(必填)";
NSMutableAttributedString *placeholder = [[NSMutableAttributedString alloc]initWithString:holderText];
[placeholder addAttribute:NSForegroundColorAttributeName
value:[UIColor redColor]
range:NSMakeRange(0, holderText.length)];
[placeholder addAttribute:NSFontAttributeName
value:[UIFont systemFontOfSize:12]
range:NSMakeRange(0, holderText.length)];
self.authCodeField.attributedPlaceholder = placeholder;
}
//3,label显示两种颜色,格式
NSString *title = [NSString stringWithFormat:@"您邀请的号码(%@)已成功注册。",model.custCode];
titleLabel.frame = CGRectMake(15, 5, KWidth-30,30);
titleLabel.font = [UIFont systemFontOfSize:15];
NSMutableAttributedString *hintString=[[NSMutableAttributedString alloc]initWithString:title];
//获取要调整颜色的文字位置,调整颜色,range表示从第七位开始后面11位的范围
[hintString addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(7, 11)];
titleLabel.attributedText = hintString;
//4,IOS10之后真机测试打印(打包的时候要注释掉,否则无法打包)
#ifdef DEBUG
#define YQLString [NSString stringWithFormat:@"%s", __FILE__].lastPathComponent
#define YQLLog(...) printf(" %s\n\n", [[NSString stringWithFormat:__VA_ARGS__] UTF8String]);
#else
#define LRLog(...)
#endif
//获取日期时间
-(void)setTimeLabelText{
NSDate* now = [NSDate date];
NSCalendar *cal = [NSCalendar currentCalendar];
unsigned int unitFlags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute |NSCalendarUnitSecond | NSCalendarUnitWeekday;
NSDateComponents *dd = [cal components:unitFlags fromDate:now];
NSInteger year = [dd year];
NSInteger mon = [dd month];
NSInteger day = [dd day];
NSInteger hour = [dd hour];
NSInteger min = [dd minute];
NSArray *weekdays = [NSArray arrayWithObjects: [NSNull null], @"日", @"一", @"二", @"三", @"四", @"五", @"六", nil];
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
NSTimeZone *timeZone = [[NSTimeZone alloc] initWithName:@"Asia/Shanghai"];
[calendar setTimeZone: timeZone];
NSCalendarUnit calendarUnit = NSCalendarUnitWeekday;
NSDateComponents *theComponents = [calendar components:calendarUnit fromDate:now];
NSString *week = [weekdays objectAtIndex:theComponents.weekday];
_timeLabel.text =[NSString stringWithFormat:@"%.2ld:%.2ld",hour,min];
_dateLabel.text = [NSString stringWithFormat:@"%.2ld/%.2ld/%.2ld 星期%@",year,mon,day,week];
}
//坐标从navigationbar开始算0
if (IS_IOS_(7)) {
if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
{
self.edgesForExtendedLayout = UIRectEdgeBottom;
}
}
//点击事件穿透
- (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event{
UIView *hitView = [super hitTest:point withEvent:event];
//穿透哪个就设置哪个,下面这个是穿过本身view和view里面的一个子view
if(hitView == self || hitView == _clearView){
return nil;
}
return hitView;
}
//遍历NSString
NSString *number = _recordArray[indexPath.row];
[number enumerateSubstringsInRange:NSMakeRange(0, number.length) options:NSStringEnumerationByComposedCharacterSequences usingBlock:^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) {
NSString *order = [NSString stringWithFormat:@"button %@",substring];
NSLog(@"=======%@",order);
// kTCSendControlBoxCmd(order);
}];
//代码退出App
UIWindow *window = self.window;
[UIView animateWithDuration:.5f animations:^{
window.alpha = 0;
window.frame = CGRectMake(0, -SCREENWIDTH, SCREENWIDTH, 0);
} completion:^(BOOL finished) {
exit(0);
}];
网友评论