代码之家  ›  专栏  ›  技术社区  ›  ohho

如何左对齐uiactionsheet的标题

  •  1
  • ohho  · 技术社区  · 14 年前

    是否可以左对齐 title A的文本 UIActionSheet ?谢谢!

    4 回复  |  直到 10 年前
        1
  •  0
  •   rpetrich    14 年前

    无法自定义 title 一个 UIActionSheet . 如果你想要类似的东西,你必须设计你自己的克隆。

        2
  •  2
  •   Ashkan_paya    12 年前

    只需在uiactionsheet中为按钮设置的名称后使用空格。例如,如果是@“download”,您可以改为@“download-------”,这里的破折号是空格。

    我希望它能奏效。

        3
  •  0
  •   Duck    12 年前

    是的,你能做到。

    NSArray *subViewArray = yourActionSheet.subviews;
    for(int x=0;x<[subViewArray count];x++){
        if([[[subViewArray objectAtIndex:x] class] isSubclassOfClass:[UILabel class]])
        {
            UILabel *label = [subViewArray objectAtIndex:x];
            label.textAlignment = NSTextAlignmentLeft;
        }
    
    }
    
        4
  •  0
  •   MD SHAHIDUL ISLAM    10 年前

    是的,这是可能的

    - (void)willPresentActionSheet:(UIActionSheet *)actionSheet {
        [actionSheet.subviews enumerateObjectsUsingBlock:^(id _currentView, NSUInteger idx, BOOL *stop) {
            if ([_currentView isKindOfClass:[UIButton class]]) {
                ((UIButton *)_currentView).contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
                ((UIButton *)_currentView).contentEdgeInsets = UIEdgeInsetsMake(0, 30, 0, 0);
            }
        }];
    }