比较tricky的做法,就是再UIAlertView中找到第二个UILabel(第一个是Title), 然后设置左对齐。

+(UIView*)findSubViewIn:(UIView*)parent OfClass:(id)classObject index:(int)index;
{
   int i = 0; for (UIView* subView in parent.subviews)
 {
    if([subView isKindOfClass:classObject])
    {
      if(i == index)
      {
         return subView;
      }
      i++;
    }
   }

return nil;

}

 

+(void)setTextAlignment:(UITextAlignment)alignment forAlertView:(UIAlertView*)view
{
  UILabel* label = (UILabel*)[Helper findSubViewIn:view OfClass:[UILabel class] index:1];
  label.textAlignment = alignment;
}

相关文章:

  • 2021-11-21
  • 2022-12-23
  • 2022-12-23
  • 2022-01-27
  • 2021-12-04
  • 2021-08-20
  • 2022-12-23
  • 2022-01-29
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-21
  • 2022-12-23
  • 2021-11-10
  • 2021-04-22
  • 2022-03-04
相关资源
相似解决方案