UITips

作者: 独孤流 | 来源:发表于2019-12-01 17:29 被阅读0次
1、计算UILabel的右侧有一条灰色的竖线

问题:在对UILabel进行frame布局时,如果计算出宽度有小数,在某些机型会导致在UILabel的右侧又一个竖线,所以需要给UILabel的宽度取整

2、UITableView偶尔在调用reloadData时会跳动

问题:在开发一个简单页面时,由于要在多个地方用到刷新数据、展开收起的功能,一开始使用reloadsections发现header有明显变化感和跳动感,然后使用reloadIndexPaths,结果会有跳动感,之后使用reloadData,跳动感减少,但偶尔还是会有

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSNumber *heightNumber = [self.cellHeightDict objectForKey:indexPath];
    CGFloat height = 50;
    if(heightNumber)
    {
        height = heightNumber.floatValue;
    }
    return height;
}

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    CGFloat cellHeight = cell.frame.size.height;
    [self.cellHeightDict setObject:@(cellHeight) forKey:indexPath];
}

系统粗体

iOS在设置里开启了粗体后内容显示不全的问题解决方式
UIButton 在粗体文本下的bug

其他解决方式:在layoutSubView里调用Button/UILabel的 sizeTofit

相关文章

  • UITips

    1、计算UILabel的右侧有一条灰色的竖线 问题:在对UILabel进行frame布局时,如果计算出宽度有小数,...

网友评论

      本文标题:UITips

      本文链接:https://www.haomeiwen.com/subject/xoazwctx.html