草庐IT

ios - 尽管启用了透明度,但半透明的导航和标签栏看起来不透明

我正在尝试使用我的自定义颜色创建一个半透明的选项卡和导航栏,但是我没有尝试启用透明度。我在网上看过,大多数人说半透明bool值默认设置为true,但是即使我也设置了它,条形图仍然保持不透明。UINavigationBar.appearance().barTintColor=UIColor.blueColor()UINavigationBar.appearance().tintColor=UIColor.yellowColor()UINavigationBar.appearance().translucent=trueUITabBar.appearance().tintColor=UIC

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

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

ios - UINavigationBar 色调颜色不更新

我正在我的应用中实现深色模式。这是我的代码(双击屏幕时调用的代码):ifdarkMode==false{UINavigationBar.appearance().tintColor=UIColor(hexString:"#3A3A3A")UINavigationBar.appearance().titleTextAttributes=[NSForegroundColorAttributeName:UIColor.whiteColor()]UIApplication.sharedApplication().statusBarStyle=UIStatusBarStyle.LightCont

ios - 为什么我不能将颜色数组中的颜色随机设置到 tableViewCells?

谁能看出为什么我不能将tableView单元格的背景颜色属性设置为我在ViewDidLoad()中创建的数组中的颜色?我的viewDidAppear()方法中也有一个self.tableView.reloadData()。让我知道。overridefuncviewDidLoad(){super.viewDidLoad()colorArray+=[UIColor.whiteColor(),UIColor.blackColor(),UIColor.greenColor(),UIColor.yellowColor(),UIColor.redColor(),UIColor.purpleColo

ios - Swift - 无法更新 UITabBar barTintColor

在viewDidLoad中,我尝试了以下方法来更新我的UITabBar的背景或“barTintColor”。我可以通过使用[[UITabBarappearance]setBarTintColor:[UIColorblackColor]];用objective-c做到这一点。我尝试过的:UITabBar.appearance().barTintColor=UIColor.whiteself.navigationController?.navigationBar.barTintColor=UIColor.white;UINavigationBar.appearance().barTintC

ios - 将 SRGB 值显示为 View 的背景色

我得到的输出是ExtendedSRGB。我给出了以下输出:我需要在UIView中显示SRGB颜色,所以它看起来像这样:self.view.backgroundColor=SRGBVALUES但是,与RGB值不同,SRGB值的范围是0..1。因此,我该如何显示颜色。[(kCGColorSpaceICCBased;kCGColorSpaceModelRGB;sRGBIEC61966-2.1)](0.7450980.74509811) 最佳答案 试试下面的代码:letsRGB=CGColorSpace(name:CGColorSpace.

ios - 如何在编辑时为 UITableViewCell 设置动画?

当用户点击表格View的编辑按钮时,您如何为表格View单元格中的颜色变化设置动画?点击编辑按钮时,Apple的动画会将所有单元格的内容向右移动,以在每个单元格中显示删除或插入按钮。我想添加我自己的动画,这些动画与Apple的动画同时出现。我已经设法为单元格布局设置了动画,但没有更改颜色。这就是我正在做的:overridefuncwillTransition(tostate:UITableViewCellStateMask){super.willTransition(to:state)letwillEdit=state.contains(.showingEditControlMask)

swift - SCNBox 使正面旋转到 ARKit 中的相机

我有一个简单的ARKit应用程序。当用户触摸屏幕时overridefunctouchesBegan(_touches:Set,withevent:UIEvent?){guardlettouch=touches.firstelse{return}letresult=sceneView.hitTest(touch.location(in:sceneView),types:[ARHitTestResult.ResultType.featurePoint])guardlethitResult=result.lastelse{return}lethitTrasform=SCNMatrix4(hi

ios11:导航栏中的 UISearchBar

我在这个answer的帮助下在我的导航栏中实现了渐变.但是,渐变不包括搜索栏。但这就是我想要的:知道问题出在哪里吗?非常感谢您提供的任何帮助。我将在下面分享我的代码。extensionUINavigationBar{funcsetGradientBackground(colors:[UIColor]){varupdatedFrame=boundsupdatedFrame.size.height+=20letgradientLayer=CAGradientLayer(frame:updatedFrame,colors:colors)setBackgroundImage(gradientL

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