按钮调整布局
- (void)layoutSubviews {
[super layoutSubviews];
self.imageView.frame = CGRectMake(20, 20, [UIScreen mainScreen].bounds.size.width / 4 - 45, [UIScreen mainScreen].bounds.size.width / 4 - 45);
self.titleLabel.frame = CGRectMake(0, [UIScreen mainScreen].bounds.size.width / 4 - 25, [UIScreen mainScreen].bounds.size.width / 4, 25);
}
搜索框键盘下落
_collectionView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
设置部分字段不同字体颜色
NSRange range = [cell.titleLabel.text rangeOfString:_searchString options:NSCaseInsensitiveSearch];
[self setTextColor:cell.titleLabel FontNumber:cell.titleLabel.font AndRange:range AndColor:[UIColor colorWithRed:0/255.0 green:188/255.0 blue:212/255.0 alpha:1]];
-(void)setTextColor:(UILabel *)label FontNumber:(id)font AndRange:(NSRange)range AndColor:(UIColor *)vaColor
{
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:label.text];
//设置字号
[str addAttribute:NSFontAttributeName value:font range:range];
//设置文字颜色
[str addAttribute:NSForegroundColorAttributeName value:vaColor range:range];
label.attributedText = str;
}
tableView去除多余行
_tableView.tableFooterView = [[UIView alloc]init];
导航跳转到某一个控制器
for (UIViewController *temp in self.navigationController.viewControllers) {
if ([temp isKindOfClass:[SuyanSDKMessageController class]]) {
[self.navigationController popToViewController:temp animated:YES];
}
}
导航条自定义跳转
NSMutableArray *array = [NSMutableArray array];
[self.navigationController.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if ([obj isKindOfClass:[XBHomeViewController class]]) {
[array addObject:obj];
}
}];
XBMyOrderViewController *detailVC = [XBMyOrderViewController controller];
[array addObject:detailVC];
[self.navigationController setViewControllers:array animated:YES];
自定义cell侧滑
-(void)layoutSubviews
{
[super layoutSubviews];
for (UIView *subView in self.subviews){
if([subView isKindOfClass:NSClassFromString(@"UITableViewCellDeleteConfirmationView")]){
UIButton* deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
deleteBtn.frame = subView.bounds;
[deleteBtn setTitle:@"取消关注" forState:UIControlStateNormal];
[deleteBtn.titleLabel setFont:[UIFont systemFontOfSize:14]];
[deleteBtn setTitleColor:[UIColor colorWithRed:253/255.0 green:206/255.0 blue:7/255.0 alpha:1] forState:UIControlStateNormal];
deleteBtn.backgroundColor = [UIColor colorWithRed:245/255.0 green:245/255.0 blue:245/255.0 alpha:1];
[subView addSubview:deleteBtn];
break;
}
}
}
present页面全部dismiss
[self.presentingViewController.presentingViewController dismissViewControllerAnimated:YES completion:^{
}];