在我的应用程序中 - 有四个按钮,命名如下:
按钮上方有一个图像视图(或UIView).
现在,假设用户点击 - 左上角按钮.上面的图像/视图应该在该特定角落四舍五入.
我在为UIView应用圆角方面遇到了一些困难.
现在我使用以下代码将圆角应用于每个视图:
// imgVUserImg is a image view on IB.
imgVUserImg.image=[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"any Url Here"];
CALayer *l = [imgVUserImg layer];
[l setMasksToBounds:YES];
[l setCornerRadius:5.0];
[l setBorderWidth:2.0];
[l setBorderColor:[[UIColor darkGrayColor] CGColor]];
Run Code Online (Sandbox Code Playgroud)
上面的代码将圆度应用于所提供视图的每个角.相反,我只想将圆度应用于选定的角落,如 - 顶部/顶部+左侧/底部+右侧等.
可能吗?怎么样?
我创建了一个文档视图,显示了角落里的页码.页码是具有半透明背景颜色的uilabel,并且具有角半径(使用s 的cornerRadius属性).我把它放在了上面.但是,这会使滚动生涩.如果我删除,性能是好的.我能做些什么吗?什么是更好的解决方案?它似乎是在没有任何性能问题的情况下实现的.viewlayerUIScrollViewcornerRadiusUIWebView
我无法找到解决问题的方法,所以我希望有些专家可以帮助我.
我有很多细胞的tableview.对于每个单元格,我有一个带圆角的图像视图:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UIImageView *exampleView;
...
exampleView.layer.cornerRadius = 5.f;
exampleView.clipsToBounds = YES;
[cell.contentView addSubview:exampleView];
...
}
Run Code Online (Sandbox Code Playgroud)
导致滚动性能问题严重不足 - 当使用cornerRadius和clipsToBounds = YES时,任何替代解决方案? (圆角图像视图包含图片,如果没有设置角落.滚动是平滑的.所以问题出在这里)
编辑#1:澄清我已阅读其他帖子:
...
exampleView.frame = CGRectMake(5.0f,size.height-15.0f,30.0f,30.0f);
exampleView.layer.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5].CGColor;
exampleView.layer.cornerRadius = 5.0f;
exampleView.layer.borderWidth = 0.3f;
exampleView.layer.borderColor = [UIColor blackColor].CGColor;
exampleView.layer.masksToBounds = NO;
exampleView.layer.shouldRasterize = YES;
//exampleView.clipsToBounds = NO;
[exampleView setImage: myImage ];
Run Code Online (Sandbox Code Playgroud)
编辑#2: 就像myImage正在研究圆角视图.如何使图像适合圆角视图?还是我错过了什么?