How to align messages in UIAlertView?

前端 未结 3 782
时光说笑
时光说笑 2021-02-04 16:16

i want to know how to set the alignment of delegate message of alert view. anyone has solution, plz reply with some code.

3条回答
  •  难免孤独
    2021-02-04 17:01

    You need to get alertView's subViews. Iterate through the array of subview's, it will be having one item of type UILable. Get that UILabel from subview array and for that you can set textAlignment property.

    NSArray *subViewArray = alertView.subviews;
     for(int x=0;x<[subViewArray count];x++){
     if([[[subViewArray objectAtIndex:x] class] isSubclassOfClass:[UILabel class]])
      {
          UILabel *label = [subViewArray objectAtIndex:x];
        label.textAlignment = UITextAlignmentCenter;
      }
    
    }
    

提交回复
热议问题