//强制横屏
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);
}];
IOS一些小方法
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 【蝴蝶效应】 蝴蝶效应:上个世纪70年代,美国一个名叫洛伦兹的气象学家在解释空气系统理论时说,亚马逊雨林一只蝴蝶...
- 今天和大家分享OHSA18001职业健康安全管理体系-关于职业病防范管理细节的话题,去很多企业审核,发现行政人事部...