iOS項目中用到的一些設置

1、屏幕常亮? [[UIApplication sharedApplication] setIdleTimerDisabled:YES];

? 退出程序時把自動休眠功能開啟

[UIApplication sharedApplication].idleTimerDisabled=NO;

2、點擊圖片瀏覽大圖? ? XWScanImage

3、關鍵字加點擊事件 ? “查看詳情” ?UILabel+YBAttributeTextTapAction

[cell.contentLabel yb_addAttributeTapActionWithStrings:@[@"[查看詳情]"] tapClicked:^(NSString *string, NSRange range, NSInteger index) {

[self didSelectwhichCell:cell];

}];

4、添加側滑返回

AllVideoViewController *videoVC = [[AllVideoViewController alloc]init];

[videoVC setHidesBottomBarWhenPushed:YES];

[self.navigationController pushViewController:videoVC animated:YES];


遵循UIGestureRecognizerDelegate

self.navigationController.interactivePopGestureRecognizer.delegate = self;

5、修改電池條顏色

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:NO];//修改電池條黑色

6、修改導航欄分割線

[self.navigationController.navigationBar setShadowImage:[UIImage imageNamed:@"Search_W bg Copy@2x"]];

7、顏色漸變

UIColor *colorOne = [UIColor colorWithRed:(0/255.0)? green:(0/255.0)? blue:(0/255.0)? alpha:0.0];

UIColor *colorTwo = [UIColor colorWithRed:(0/255.0)? green:(0/255.0)? blue:(0/255.0)? alpha:1.0];

NSArray *colors = [NSArray arrayWithObjects:(id)colorOne.CGColor, colorTwo.CGColor, nil];

CAGradientLayer *gradient = [CAGradientLayer layer];

//設置開始和結束位置(設置漸變的方向)

gradient.startPoint = CGPointMake(0, 0);

gradient.endPoint = CGPointMake(0, 1);

gradient.colors = colors;

gradient.frame = CGRectMake(0, 0, SCREENH_HEIGHT, 56);

[self.btnView.layer insertSublayer:gradient atIndex:0];

8、設置陰影

whiteView.layer.masksToBounds = NO;

whiteView.layer.cornerRadius = 4.0;

//? ? whiteView.layer.borderColor = [@"#333842" hexStringToColor].CGColor;

//? ? whiteView.layer.borderWidth = 0.5;

whiteView.layer.shadowColor = [@"#333842" hexStringToColor].CGColor;//shadowColor陰影顏色

whiteView.layer.shadowOffset = CGSizeMake(0,4);//shadowOffset陰影偏移,x向右偏移4,y向下偏移4,默認(0, -3),這個跟shadowRadius配合使用

whiteView.layer.shadowOpacity = 0.1;//陰影透明度,默認0

whiteView.layer.shadowRadius = 10.0;//陰影半徑,默認3

9、設置字間距

NSDictionary *lineDic = @{NSKernAttributeName:@1.f,NSFontAttributeName:[UIFont fontWithName:@"PingFang-SC-Medium" size:16]};//字間距

NSMutableAttributedString * attributedString = [[NSMutableAttributedString alloc] initWithString:dict[@"title"] attributes:lineDic];

NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle alloc] init];

//? ? ? ? ? ? ? ? ? ? [paragraphStyle setLineSpacing:24];//行間距

[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [dict[@"title"] length])];

[_titleLab setAttributedText:attributedString];

10、獲取點擊某個cell上的按鈕

[cell.replyBtn addTarget:self action:@selector(replyThumpAction:event:) forControlEvents:UIControlEventTouchUpInside];//評論里回復的點贊


- (void)thumpAction:(UIButton *)btn event:(id)event{

NSSet *touches =[event allTouches];

UITouch *touch =[touches anyObject];

CGPoint currentTouchPosition = [touch locationInView:self.MyTable];

NSIndexPath *idx= [self.MyTable indexPathForRowAtPoint:currentTouchPosition];

//? ? ? ? NSInteger index = btn.tag - 1000;

CommentListObj *obj = self.dataArr[idx.row];

}


11、設置textField的占位字的字體和顏色

[_NewField setValue:[@"#CCCCCC" hexStringToColor] forKeyPath:@"_placeholderLabel.textColor"];

[_NewField setValue:[UIFont fontWithName:@"PingFangSC-Regular" size:15] forKeyPath:@"_placeholderLabel.font"];

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容