模糊的iOS7 TableViewCell内容

时间:2014-04-08 13:20:26

标签: ios objective-c ios7 uitableview

自从我的应用程序更新到iOS7后,我一直在努力应对一些模糊元素。

特别是,在一个自定义单元格中,所有UILabelUISlider都显得模糊。 我用整数值设置帧,所以我假设子像素渲染不是来自单元格布局本身,而是与superview有关吗?

自定义单元格自然位于UITableView内,除导航栏外全屏,并且处于模态视图中。

- (void)reuseCellWithQuestion:(Question *)currentQuestion  {
    self.backgroundColor = [UIColor clearColor];
    self.contentView.backgroundColor = [UIColor clearColor];
    for (UIView *eachView in self.contentView.subviews) {
        [eachView removeFromSuperview];
    }
    NSString *currentQuestionTitle = [NSString stringWithFormat:@"%@. %@", currentQuestion.questionNumber, currentQuestion.body];
    NSArray *optionsArray = [currentQuestion.answerLabels componentsSeparatedByString:kPLAnswerLabelSeparator];

    int headerFontSize = 20;
    int labelFontSize = 16;
    UIFont *headerFont = [UIFont systemFontOfSize:headerFontSize];
    UIFont *labelFont = [UIFont systemFontOfSize:labelFontSize];

    int totalWidth = ([[UIApplication sharedApplication] statusBarOrientation]>2) ? 1024 : 768;
    int leftMargin = 20;
    int topMargin = 20;
    int horizontalPadding = 10;
    int verticalPadding = 10;

    int headerWidth = totalWidth - leftMargin*2;
    int headerHeight = 40;
    int labelWidth = 200;
    int labelHeight = 60;
    int sliderWidth = totalWidth - leftMargin*2 - labelWidth*2 - horizontalPadding*2;
    int sliderHeight = labelHeight;

    CGRect headerLabelFrame = CGRectIntegral(CGRectMake(leftMargin, topMargin, headerWidth, headerHeight));
    CGRect leftLabelFrame = CGRectIntegral(CGRectMake(leftMargin, topMargin + headerHeight + verticalPadding, labelWidth, labelHeight));
    CGRect rightLabelFrame = CGRectIntegral(CGRectMake(leftMargin + labelWidth + horizontalPadding*2 + sliderWidth, topMargin + headerHeight + verticalPadding, labelWidth, labelHeight));
    CGRect sliderFrame = CGRectIntegral(CGRectMake(leftMargin + labelWidth + horizontalPadding, topMargin + headerHeight + verticalPadding, sliderWidth, sliderHeight));

    UILabel *headerLabel = [[UILabel alloc] initWithFrame:headerLabelFrame];
    headerLabel.textAlignment = UITextAlignmentCenter;
    headerLabel.text = currentQuestionTitle;
    headerLabel.font = headerFont;
    headerLabel.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:headerLabel];
    [headerLabel release];

    UILabel *leftLabel = [[UILabel alloc] initWithFrame:leftLabelFrame];
    leftLabel.textAlignment = UITextAlignmentLeft;
    leftLabel.text = [optionsArray objectAtIndex:0];
    leftLabel.font = labelFont;
    leftLabel.numberOfLines = 0;
    leftLabel.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:leftLabel];
    [leftLabel release];

    UILabel *rightLabel = [[UILabel alloc] initWithFrame:rightLabelFrame];
    rightLabel.textAlignment = UITextAlignmentRight;
    rightLabel.text = [optionsArray objectAtIndex:1];
    rightLabel.font = labelFont;
    rightLabel.numberOfLines = 0;
    rightLabel.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:rightLabel];
    [rightLabel release];

    UISlider *tempSlider = [[UISlider alloc] initWithFrame:sliderFrame];
    tempSlider.minimumTrackTintColor = [UIColor lightGrayColor];
    tempSlider.maximumTrackTintColor = [UIColor lightGrayColor];
    tempSlider.thumbTintColor = [UIColor plColor];
    tempSlider.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:tempSlider];
    self.theSlider = tempSlider;
    [tempSlider release];
}

我不确定从哪里开始?我已尝试在CGRectIntegral方法和自定义单元格代码中同时使用cellFromRowWithIndexPath

感谢任何帮助。


编辑:截图如下 Screenshot Screenshot 2

0 个答案:

没有答案