转载自:http://hi.baidu.com/marktian/item/8c727012013ecca1feded5f8
项目中的代码如下:
- (void)initTableView
{
if (!_headView){
[self
createHeadView];
}
if (!_tableView) {
_tableView = [[UITableView
alloc] initWithFrame:self.view.bounds
style:UITableViewStyleGrouped];
}
_tableView.dataSource =self;
_tableView.delegate =
self;
_tableView.backgroundColor = [UIColor
clearColor];
_tableView.backgroundView =
nil;
_tableView.clipsToBounds =
YES;
_tableView.showsHorizontalScrollIndicator =
NO;
_tableView.showsVerticalScrollIndicator =
NO;
_tableView.autoresizingMask =
UIViewAutoresizingFlexibleHeight;
_tableView.tableHeaderView =
_headView;
_tableView.separatorColor = [UIColor
colorWithRed:211.f/255.f
green:215.f/255.f
blue:221.0f/255.0f
alpha:1.0f];
[self.view
addSubview:_tableView];
}
如题,有两个view: view1,view2
view2添加view1到中,如果view2大于view1,或者view2的坐标不全在view1的范围内,view2是盖着view1的,意思就是超出的部份也会画出来
UIView有一个属性,clipsTobounds 默认情况下是NO。
如果,我们想要view2把超出的那部份隐藏起来的话,就得改变它的父视图也就view1的clipsTobounds属性值。
view1.clipsTobounds = YES;
no的情况:

yes的情况:

ZZ FROM COCOACHINA