【问题标题】:how to make UITableViewCell contentview mask UILabel to create core animation scrolling text如何使 UITableViewCell contentview mask UILabel 创建核心动画滚动文本
【发布时间】:2011-09-17 01:39:47
【问题描述】:

我正在尝试创建一个 UITable,其中单元格显示一些文本,并且当文本大于单元格的 contentview(即,直到附件类型)时,文本应该做一个滚动动画来显示所有自己。

我已经设法完成了。也就是说,我让文本滚动,但是:

  • 我尝试使用单元格的 contentview 边界来剪辑文本,以便它滚动但在单元格的左端和附件之前的内容视图的右端剪辑。但这不起作用:contentview 总是有整个 iphone 屏幕的宽度? (320)。

  • 我还尝试向 contentView 添加一个新的 UIView,并设置大小。不过,它没有剪辑。

基本上,我让文本滚动,但它滚动过去(并越过)附件和左边缘。

非常感谢任何帮助。

【问题讨论】:

    标签: iphone ios cocoa-touch uitableview


    【解决方案1】:

    您是否尝试将任何视图上的 clipsToBounds 属性设置为“是”?可能无法在 contentView 上工作,但如果您使用固定大小的 UIView 子视图想法将其剪辑设置为边界,我认为它应该可以工作。像这样的:

    UIView *subview = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 250.0, myTableViewCell.contentView.bounds.size.height)];
    subview.clipsToBounds = YES;
    [myTableViewCell.contentView addSubview:subview];
    
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, 10000.0, subview.bounds.size.height)];
    label.text = @"Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.";
    [subview addSubview:label];
    
    // make animation happen
    
    [subview release];
    [label release];
    

    【讨论】:

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