开发者

UIView layer problems

开发者 https://www.devze.com 2023-03-05 20:39 出处:网络
I have a problem with UIViews, I have a white UIView with the frame 240*320, and a black UIView with the frame 480*20 and I add the white view to my landscape mainView which is 480*320 and then I add

I have a problem with UIViews, I have a white UIView with the frame 240*320, and a black UIView with the frame 480*20 and I add the white view to my landscape mainView which is 480*320 and then I add the black view to the white view, and the black view is not only above the white view but also above the mainView, and I don't want to be above the mainView, does anybody know a solution?, this is the code:


    UIView *aView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 240, 320)];
    UIView *otherView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 480, 20)];
    [aView setBackgroundColor:[UIColor whiteColor]];
    [otherView setBackgroundColor:[UIColor blackColor]];
    [开发者_如何转开发aView addSubview:otherView];
    [[self view] addSubview:aView];


what about this:

aView.clipsToBounds = YES;


use this thing to manage views.

[self.view bringsubviewtofront:uiview]; and also use the [self.view bringsubviewtoback:uiview];

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号