jjzjj

BackgroundColor

全部标签

iphone - 如何根据位置修改空 UITableViewCell 对象的背景颜色?

我正在尝试编写代码以根据单元格在表格中的位置修改单元格的背景颜色。虽然以下代码“有效”,但它只会影响传递给它的单元格。空单元格不会受到影响。-(void)tableView:(UITableView*)tableViewwillDisplayCell:(UITableViewCell*)cellforRowAtIndexPath:(NSIndexPath*)indexPath{if(!indexPath.row%2){cell.backgroundColor=[UIColorcolorWithRed:0.0green:0.0blue:1.0alpha:1.0];NSLog(@"Blue

ios - didDeselectRowAtIndexPath 没有在 UITableView 的第一行被调用

这个问题在这里已经有了答案:WhenIselectaUITableViewCell,myviewcontrollerlabelisanactionbehind(1个回答)关闭8年前。我的UITableView出现了一个奇怪的问题。每当我按下UITableView的第一行时,都不会调用didDeselectRowAtIndexPath方法。我目前的代码如下。#pragmamark-UITableViewDelegate&UITableViewDataSource-(NSInteger)tableView:(UITableView*)tableViewnumberOfRowsInSecti

ios - 更改突出显示的 UIButton BG 颜色,但保留层角半径?

我正在通过这个类别方法更改UIButton的背景颜色,使用1pxx1px图像:-(void)setBackgroundColor:(UIColor*)backgroundColorforState:(UIControlState)state{UIGraphicsBeginImageContextWithOptions(CGSizeMake(1,1),NO,0);[backgroundColorsetFill];CGContextFillRect(UIGraphicsGetCurrentContext(),CGRectMake(0,0,1,1));UIImage*backgroundIm

ios - 带有图像而不是标题的 UITableViewRowAction

我想做一个像邮件应用一样的cell滑动Action。我将UIImage设置为行操作的backgroundColor。action.backgroundColor=[UIColorcolorWithPatternImage:[UIImageimageNamed:@"remove"]];但是我的图像在背景上并排重复。像这样。图片大小问题?可以告诉我如何修复它或其他方法吗? 最佳答案 是的,这是图像尺寸问题。甚至我也有类似的要求并面临同样的问题。在这种情况下,当您使用时,action.backgroundColor=[UIColorcol

ios - 将子层添加到 UICollectionViewCell 时出现意外行为

在下面的最小示例中,我创建了一个包含五个UICollectionViewCell的UICollectionView。对于每一个,我创建一个具有相同frame的CALayer并设置其backgroundColor属性并将其作为子层添加到UICollectionViewCell的layer属性。最初在屏幕上的单元格按预期设置,但其余单元格的颜色可能不正确,并且在滚动时可能会在完全离开屏幕之前消失。这个问题[1]表明发生这种情况是因为单元格最初不在屏幕上(?),但我从答案中看不出如何解决该问题。下面是一个最小的工作示例。我尝试过的一些事情被注释掉了:直接设置单元格的背景颜色,以确保这不是我设

swift - 如何在 button.addTarget Action 中发送多个按钮? swift 3

如何将按钮和按钮2发送到我的pressButton2函数中?当用户触摸button2时,我需要更改button和button2的颜色...当我的button2.addTarget看起来像这样时,我得到了一个错误:“表达式列表中的预期表达式”。importUIKitclassViewController:UIViewController{overridefuncviewDidLoad(){super.viewDidLoad()//Doanyadditionalsetupafterloadingtheview,typicallyfromanib.letbutton=UIButton(fra

ios - 如何同时设置keyboardAppearance和inputView?.backgroundColor为dark?

我有datePicker,我将其设置为textField的inputView。importUIKitclassViewController:UIViewController{@IBOutletweakvartextField:UITextField!vardatePicker:UIDatePicker=UIDatePicker()overridefuncviewDidLoad(){super.viewDidLoad()datePicker.datePickerMode=.datedatePicker.setValue(UIColor.white,forKeyPath:"textColo

ios - 在 Swift 中使用 Objective-C 类时为 "Cannot Find Initializer"

第一次创建Swift应用程序时一切顺利,直到我在尝试将Objective-C类用于SwiftViewController时遇到问题。Objective-C类初始化(RKDropdownAlert.h)+(void)title:(NSString*)titlemessage:(NSString*)messagebackgroundColor:(UIColor*)backgroundColortextColor:(UIColor*)textColortime:(NSInteger)seconds;我的尝试:varalert:RKDropdownAlert=RKDropdownAlert(t

ios - 如何快速获取 UIButton 颜色

我有带背景颜色的UIButton,现在我想在单独的颜色字段中设置该按钮颜色我试过这个方法:初始化:varcolor1=UIColor()color1=dateBtn1.backgroundColor!设置:ifcolor1==UIColor.lightGrayColor(){dateBtn1.backgroundColor=UIColor.lightGrayColor()}else{dateBtn1.backgroundColor=UIColor(red:85/255,green:175/255,blue:101/255,alpha:1.0)}我的崩溃报告:Terminatingapp

ios - Swift 4 backgroundColor 错误?

我的View透明度有问题,尤其是UITableView。只是为了确定。我已经有3年的swift经验,这是我第一次遇到这个问题。所以在apple的文档中它说了以下内容:背景颜色View的背景颜色。此属性的更改可以动画化。默认值为nil,这会产生透明的背景颜色。”但是当对backgroundColor或tableView.backgroundColor=UIColor.clear应用清晰颜色时,背景仍然显示为白色。这是错误还是功能?编辑:tableView不再是问题。它是tableView中的单元格。已经尝试过的解决方案正在清除所有subview的背景颜色。什么都没有改变。编辑29.09.