相关疑难解决方法(0)

如何在iPhone上创建圆角UILabel?

是否有内置的方法来创建圆角UILabels?如果答案是否定的,那么如何创建这样的对象呢?

cocoa-touch objective-c rounded-corners uilabel ios

149
推荐指数
11
解决办法
13万
查看次数

UILabel的Corner Radius属性在iOS 7.1中不起作用

我正在设置cornerRadius属性UILabel.它的工作正常所有版本iOS < 7.1.以下代码我用过,

UILabel *originaltagLbl = [[UILabel alloc]initWithFrame:CGRectMake(startX, startY, 100,30)];    
[originaltagLbl setFont:[UIFont fontWithName:@"MuseoSans-500" size:15]];
[originaltagLbl setTextAlignment:NSTextAlignmentCenter];
[originaltagLbl setTextColor:UIColorFromRGB(0xffffff)];
originaltagLbl.backgroundColor = [UIColor redColor];
originaltagLbl.layer.cornerRadius = 5;
originaltagLbl.layer.borderColor = [UIColor redColor].CGColor;
originaltagLbl.layer.borderWidth = 1;
[scrollView addSubview:originaltagLbl];
Run Code Online (Sandbox Code Playgroud)

如果我使用它,只需将标签显示为rectanglular box,那么如何设置UILabelin 的角半径iOS 7.1

iphone objective-c ios ios7.1

43
推荐指数
2
解决办法
3万
查看次数

Tableview滚动使用cornerRadius缺乏性能,什么是替代品?

我无法找到解决问题的方法,所以我希望有些专家可以帮助我.

我有很多细胞的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正在研究圆角视图.如何使图像适合圆角视图?还是我错过了什么?

rounded-corners uitableview ios

11
推荐指数
1
解决办法
5188
查看次数

向每个单元格添加带有cornerRadius的UILabel时,UITableView会爬行

我正在为表视图中的每个单元格添加一个UILabel.这最初没有问题.当我使用layer.cornerRadius滚动来围绕UILabel的角落时,表格视图停止.

 UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(cell.bounds.origin.x+10 ,5, 30, 30)];
 label1.backgroundColor = ([[managedObject valueForKey:@"color"] hasPrefix:@"FFFFFF"]) ? [UIColor blackColor] : color;
 label1.layer.cornerRadius = 10.0f;
 [cell addSubview:label1];
Run Code Online (Sandbox Code Playgroud)

cornerradius uitableview uilabel ios

8
推荐指数
2
解决办法
4781
查看次数

UIView:没有性能问题的圆角

我正在使用AQGridView在iPad上的网格中显示我的数据.每个单元格都是一个UIView子类,通常,同时显示18个单元格.

我想为这些单元格添加一个圆角,所以我设置cornerRadius了相关图层的属性(即主要UIView和一个子视图的图层).但是,这会导致性能问题,并且滚动不再平滑.当使用其他CALayer属性时,例如shadowOpacity,这不会发生.

有没有其他方法可以添加圆角(除了使用图像)?或者我做错了什么?

iphone rounded-corners calayer uiview aqgridview

7
推荐指数
1
解决办法
4457
查看次数

iOS:当视图背景颜色为清晰颜色时,不显示图层背景颜色

我有两个兄弟视图:灰色标签和绿色按钮,按钮位于下方.出于某种原因,我需要设置label.backgroundColor为清除颜色并设置label.layer.backgroundColor为灰色.按钮颜色为绿色.我希望在屏幕上看到灰色(因为标签位于按钮顶部).但我看到的只是绿色(按钮的颜色).为什么?

编辑:相关代码

// in my custom cell
-(void)awakeFromNib
{
    [super awakeFromNib];

    // customize label
    _label.layer.cornerRadius = 5;
    _label.layer.backgroundColor = [UIColor grayColor].CGColor;
    _label.backgroundColor = [UIColor clearColor];
    _label.layer.masksToBounds = NO;


    // customize button        
    // show shadow and rounded corner at the same time

    _button.backgroundColor = [UIColor clearColor];
    _button.layer.backgroundColor = [UIColor greenColor].CGColor;
    _button.layer.masksToBounds = NO;
    _button.layer.cornerRadius = 10.0f;

    self.layer.masksToBounds = NO;
    self.layer.cornerRadius = 10.0f;
    self.layer.shadowOpacity = 0.5f;
    self.layer.shadowPath = [UIBezierPath bezierPathWithRoundedRect:_button.bounds cornerRadius:10.0f].CGPath;
    self.layer.shadowOffset = CGSizeMake(0.0f, 4.0f);
    self.layer.shadowRadius = 2.0f; …
Run Code Online (Sandbox Code Playgroud)

ios

4
推荐指数
1
解决办法
1万
查看次数