Vertical text in a Horizontal UIButton

前端 未结 5 1811
借酒劲吻你
借酒劲吻你 2021-01-21 10:01

I\'m using a vertical UIButton in a portrait app (Just a normal button that is of width 60 and Height 160)

I want to put the label Vetically down the button instead of a

5条回答
  •  暖寄归人
    2021-01-21 10:48

    You can add a Label on button and rotate the label as below:

    UILabel *lbl= [[UILabel alloc] initWithFrame:CGRectMake(button.frame.size.width*.3, button.frame.size.height*.5, button.frame.size.width,button.frame.size.height)];
    lbl.transform = CGAffineTransformMakeRotation(M_PI / 2);
    lbl.textColor =[UIColor whiteColor];
    lbl.backgroundColor =[UIColor clearColor];
    [button addSubview:lbl];
    

提交回复
热议问题