UIView里面的UIImageView更大

时间:2011-05-26 19:12:42

标签: objective-c xcode

我有一个更大的UIImageView的UIView。有没有办法隐藏超出视图大小的东西?

CGRect baseFrame = CGRectMake(100, 100, 300, 80);
UIView *baseView = [[UIView alloc] initWithFrame:baseFrame];
[self.view addSubview:baseView];
[baseView release];


UIImageView *baseBg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 300, 335)];
[baseBg setImage: [UIImage imageNamed:[NSString stringWithFormat:@"baseView.png"]]];
[baseView addSubview: baseBg];
[baseBg release];

非常感谢!

1 个答案:

答案 0 :(得分:7)

UIView.clipsToBounds = YES

UIView Class Reference