小编Tim*_*Tim的帖子

Iphone UIButton背景颜色

UIButton在循环中以编程方式创建了一些s但是我在设置按钮的背景颜色方面遇到了一些问题.

按钮的颜色始终显示为白色.但是我只使用backgroundcolor中的2种颜色.例如:红色:255绿色:0蓝色:200

这是我用来添加按钮的代码.

    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(80, 20 + (i*75), 200, 75);
    button.layer.cornerRadius = 10;
    button.layer.borderWidth = 1;
    [button setTitle:@"saf" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(moveLocation:) forControlEvents:UIControlEventTouchUpInside];
    [button setBackgroundColor:[UIColor colorWithRed:255 green:180 blue:200 alpha:1]];
    button.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    [scrollView addSubview:button];
Run Code Online (Sandbox Code Playgroud)

iphone objective-c background-color uibutton

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

无法在捆绑中加载NIB

*由于未捕获的异常'NSInternalInconsistencyException'而终止应用程序,原因:'无法在bundle中加载NIB:'NSBundle(loaded)',名称为'ViewLecturer'

ViewLecturer *viewLecturer = [[ViewLecturer alloc]initWithNibName:@"ViewLecturer" bundle:nil];

[self.navigationController pushViewController:viewLecturer animated:YES];
Run Code Online (Sandbox Code Playgroud)

我检查了文件类型,它是file.xib.
双重检查xib名称是ViewLecturer但我仍然经常在设备上得到错误.虽然在刺激器上工作正常.

iphone xcode objective-c

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

标签 统计

iphone ×2

objective-c ×2

background-color ×1

uibutton ×1

xcode ×1