草庐IT

passive-view

全部标签

ios - 导航栏中的渐变与其下方的 View 不同。

我想要达到的目标设计是下图:我使用下面的代码创建了渐变,并借助imagefromlayer函数将其设置到导航栏。funcimage(fromLayerlayer:CALayer)->UIImage{UIGraphicsBeginImageContext(layer.frame.size)layer.render(in:UIGraphicsGetCurrentContext()!)letoutputImage=UIGraphicsGetImageFromCurrentImageContext()UIGraphicsEndImageContext()returnoutputImage!}/

ios - 在 View Controller 之间传递对象

最近我一直在开发一个新的应用程序,我正在努力在ViewController之间传递数据。我使用一个ViewController,它包含一个容器View,我在其中使用谷歌地图。正如你们中的一些人所知,在谷歌地图上放置一个按钮是不可能的,因为它覆盖了所有内容(这就是我将其作为容器View放置的原因)。现在我遇到了一个问题,我无法创建一个可以performSegue的操作按钮,而且我也未能通过NotificationCenter传递一个对象。我制作了一个名为Song的模型,我想将歌曲List传递给其他Controller(表格View)。classSong{varsid:Stringvars

ios - 滚动 UICollectionView 时如何自定义在顶部屏幕上粘滞的标题 View ?

我的UICollectionView中有header(header:UICollectionReusableView)。header有3个UIView(UIView1,UIView2,UIView3)。当我设置collectionLayout.sectionHeadersPinToVisibleBounds=true时,标题将在我滚动集合时位于顶部。我希望当header位于UICollectionView顶部时,我将隐藏UIView1和UIView2。我怎样才能做到这一点? 最佳答案 UICollectionView是UIScrol

ios - 如何在表格 View 中正确设置动态标题 View ?

我需要一个部分的标题View是UIImageView和它下面的UILabel。ImageView的高度一旦创建就不会改变,但标签中的文本可能会因某些用户操作而改变。我需要动态更新整个标题View的高度(使用AutoLayout,不更改框架)。我一直在检查一些帖子,例如thisone,但我尝试过的解决方案对我不起作用。当我更改标签中的文本时,标题View的高度没有更新。也许我需要从一开始就了解它是如何工作的。首先,我想澄清一下:在tableView(_:viewForHeaderInSection:)中将标题View作为UIView的子类提供与将其作为UITableViewHeaderF

ios - 拖动到弹出 View Controller 会导致固定在底部的按钮跳转(使用标签栏)

我在使用标签栏Controller时遇到问题。见下图:按钮固定在安全区域底部。第一次按下ViewController时,它会出现在正确的位置。在viewWillAppear中,我有以下代码:overridefuncviewWillAppear(_animated:Bool){super.viewWillAppear(animated)tabBarController?.tabBar.isHidden=true}推送此Controller的ViewController在viewWillAppear中具有以下内容:overridefuncviewWillAppear(_animated:B

ios - 隐藏音量 HUD(避免使用加载 View )

这个问题不重复:HidevolumeHUDviewinMPVolumeViewHidedeviceVolumeHUDviewwhileadjusitngvolumewithMPVolumeViewsliderI'dliketohidethesystemvolumeHUDwhileadjustingthevolumeprogrammatelywithouttheneedofaloadedView.所以这个解决方案不是我想要得到的(在我的情况下这是NotAcceptable):letvolumeView=MPVolumeView(frame:.zero)view.addSubview(vo

ios - 我正在尝试在 Swift 中添加 MDCCard 以使用 Material Components 获取 Material Card View。错误 : No such module 'MaterialComponents.MaterialCards'

我正在学习本教程-https://material.io/components/ios/catalog/cards/它告诉我除了pod'MaterialComponents'之外还要添加pod'MaterialComponents/Cards'在运行podinstall时,出现以下错误-CocoaPodscouldnotfindcompatibleversionsforpod"MaterialComponents/Cards"否则,XCode无法找到MaterialCards组件-importMaterialComponents.MaterialCards给出错误-Nosuchmodu

ios - WKHTTPCookieStorage 的 setCookie 在关闭和打开 Web View 后不返回

我有下面的代码,可以将cookie从一般HTTPCookieStorage复制到我的webview的cookie存储中。复制所有cookie后,我加载webviewletwebView=WKWebView(frame:containerView.bounds,configuration:WKWebViewConfiguration())webView.navigationDelegate=navigationDelegatecontainerView.addAndFillSubview(webView)guardletsharedCookies=HTTPCookieStorage.sh

ios - Swift - 通过网络调用和 Storyboard 在 View Controller 中进行依赖注入(inject)?

Swift-如何在从Storyboard创建的ViewController中实现依赖注入(inject),并且应该注入(inject)的数据是从网络中获取的(将在异步调用后可用)?例如,ViewController显示一个列表。为了获取列表的数据集,应该执行网络调用,然后将数据注入(inject)dataSet属性。如何实现? 最佳答案 我不确定是否完全理解您的问题,但这是我通常的做法。假设您有一个DataFetcher类,负责进行网络调用:classDataFetcher{funcfetchData(completion:@esc

ios - 在 web View 中拦截加载的 javascript 文件

我正在使用WKWebView制作网页View应用leturl=NSURL(string:"http://www.example.com")letrequest=NSURLRequest(url:url!asURL)homeWebView.load(requestasURLRequest)ButIwanttointerceptsomejavaScriptfileofthiswebsitebeforeitloadstochangefunctionalityandmaketheappabitnativelooking如有任何帮助,我们将不胜感激。谢谢。 最佳答案