圆角全底屏适用于人像&景观模式?

时间:2013-07-12 05:46:09

标签: ios image uiview landscape portrait

我想在我的UIView上添加圆角图像,所以我制作了两张12x12px圆角的图像。

我想知道如何最好地添加我的视图,考虑到他必须在整个屏幕的底部以纵向和横向模式自动对齐!

这就是我现在所做的,但这不起作用:

CGSize result = [[UIScreen mainScreen] bounds].size;


        self.brcLeft = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, result.height-12.0, 12.0, 12.0)];
        self.brcLeft.image = [UIImage imageNamed:@"brc-left"];
        [self.view addSubview:brcLeft];

        self.brcRight = [[UIImageView alloc] initWithFrame:CGRectMake(result.width-12.0, result.height-12, 12.0, 12.0)];
        self.brcRight.image = [UIImage imageNamed:@"brc-right"];
        [self.view addSubview:brcRight];

1 个答案:

答案 0 :(得分:0)

要将视图设置为屏幕底部的两个方向,请执行以下操作:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation   
{  
     CGRect screenFrame = [[UIScreen mainScreen] bounds];
    [self.brcLeft setFrame:CGRectMake(0.0, screenFrame.size.height - self.brcLeft.frame.size.height , 12.0, 12.0)];

[self.brcRight setFrame:CGRectMake(result.width-12.0, screenFrame.size.height - self.brcRight.frame.size.height , 12.0, 12.0)];
    return YES;

}

和圆角:

#import <QuartzCore/QuartzCore.h>

在viewDidLoad中写下这个

self.brcLeft.layer.cornerRadius = 2;
self.brcLeft.layer.masksToBounds = YES;

self.brcRight.layer.cornerRadius = 2;
self.brcRight.layer.masksToBounds = YES;