【问题标题】:UILabel text alignment is distorted after rotationUILabel 文本对齐在旋转后扭曲
【发布时间】:2014-01-28 11:13:07
【问题描述】:

我的问题标签的问题场景:

  1. 以纵向模式查看屏幕

  1. 按主页按钮
  2. 旋转设备
  3. 再次查看屏幕

这里是按钮的声明: UIView *bottomButtons = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.width, kBottomButtonsHeight)];

    CGFloat buttonWidth = self.tableView.width/2.0;
    self.cancelButton = [[MobliButton alloc] initWithFrame:CGRectMake(0, 0, buttonWidth, kBottomButtonsHeight)];
    self.cancelButton.backgroundColor = [UIColor colorFromHexString:@"B3B3B3"];
    [self.cancelButton addTarget:self action:@selector(dismiss) forControlEvents:UIControlEventTouchUpInside];
    [self.cancelButton setTitle:NLS(@"Cancel") forState:UIControlStateNormal];
    [self.cancelButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.cancelButton.titleLabel.font = [UIFont fontWithName:@"HelveticaNeue-Light" size:16.0];
    self.cancelButton.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin;

    ....

    [self.tableView setTableFooterView:bottomButtons];

【问题讨论】:

  • 这对我来说似乎是错误的UIViewAutoresizingFlexibleRightMargin
  • @Desdenova,你有什么建议?
  • 我会尝试灵活的左下角来取消和灵活的右下角来完成按钮。
  • @Desdenova。就是这样:self.cancelButton.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin;self.nextButtonView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin;

标签: ios objective-c uilabel


【解决方案1】:

试试这个。你的情况正好相反。我还会为它们添加一个灵活的底部边距,以确保两种屏幕尺寸都适用。

self.cancelButton.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin;

self.nextButtonView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin;

祝你好运。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多