TableCell 中label的旋转

来源:互联网 发布:人像素描书 知乎 编辑:程序博客网 时间:2024/04/20 08:40

当一个TableCell中有lable,想要旋转这个label,如果这个label 是从xib中加载过来的, 最开始显示的时候,都是没有旋转的,只有当滑动,重新加载这个cell的时候,label才会旋转,

解决办法:

手动添加lable,而不是从xib中加,

UILabel *label  = [[UILabelalloc ] initWithFrame:CGRectMake(284*[UIScreenmainScreen].bounds.size.width/320, (115-103)/2,28,103)];

       

        [self.contentViewaddSubview:label];

    //旋转90度

            label.transform = CGAffineTransformMakeRotation(M_PI_2);

//还需要重新设置frame

            CGRect frame = label.frame;

            frame = CGRectMake(284*[UIScreenmainScreen].bounds.size.width/320, (115-103)/2,28, 103);

           label.frame = frame;



0 0
原创粉丝点击