iPhone单元测试重叠绘图
我正在对 UITableViewCell 进行子类化,并通过在 NSString 对象上调用 drawInRect:
来手动绘制其内容视图。这是我的代码的简化示例:
- (void)drawContentView:(CGRect)rect {
CGSize nameSize = [self textSizeForName:self.name];
[self.name drawInRect:CGRectMake(kPadding, kPadding,
nameSize.width, nameSize.height)];
CGSize blurbSize = [self textSizeForBlurb:self.blurb];
[self.blurb drawInRect:CGRectMake(kWindowWidth - blurbSize.width - kPadding,
kPadding, blurbSize.width, blurbSize.height)];
}
有没有一种方法可以编写单元测试用例,以确保它没有重叠,并且我的逻辑在避免我正在绘制的各个字符串之间发生冲突方面是正确的?
I am subclassing a UITableViewCell and drawing its content view manually by calling drawInRect:
on NSString objects. Here is a simplified sample of my code:
- (void)drawContentView:(CGRect)rect {
CGSize nameSize = [self textSizeForName:self.name];
[self.name drawInRect:CGRectMake(kPadding, kPadding,
nameSize.width, nameSize.height)];
CGSize blurbSize = [self textSizeForBlurb:self.blurb];
[self.blurb drawInRect:CGRectMake(kWindowWidth - blurbSize.width - kPadding,
kPadding, blurbSize.width, blurbSize.height)];
}
Is there a way to write a unit test case to make sure that none of it is overlapping and that my logic is right in avoiding collisions between the various strings I am drawing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论