UIlable上下居中

- (void)setView{

    

    self.chooseImg = [[UIImageView alloc] initWithFrame:CGRectMake(TO_LEFT_D, (ROW_HEIGHT-CHOOSE_IMG_WH)/2, CHOOSE_IMG_WH, CHOOSE_IMG_WH)];

    [self.contentView addSubview:self.chooseImg];

    

    self.titleLb = [[UILabel alloc] init];

    self.titleLb.numberOfLines = 0;

    [self.titleLb sizeToFit];

    self.titleLb.baselineAdjustment = UIBaselineAdjustmentAlignCenters;

    self.titleLb.textColor = [UIColor hex33Color];

    [self.contentView addSubview:self.titleLb];

    

}

- (void)setTitleStr:(NSString *)titleStr{

    self.titleLb.text = titleStr;

    self.titleLb.frame = CGRectMake(CGRectGetMaxX(self.chooseImg.frame)+10, 0, WWIDTH-CGRectGetMaxX(self.chooseImg.frame)-20, ROW_HEIGHT);

}

文字上下居中

 

猜你喜欢

转载自www.cnblogs.com/cnxBK/p/9365698.html