0

我想在我的 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];
4

1 回答 1

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;
于 2013-07-12T06:12:09.427 回答