草庐IT

ios - 将圆角半径应用于 Storyboard 中的特定 UIView 角不适用于所有角

我为此制作了一个自定义类。但它仅适用于左上角,不适用于其他角:@IBDesignablepublicclassRoundedView:UIView{@IBInspectablepublicvartopLeft:Bool=false@IBInspectablepublicvartopRight:Bool=false@IBInspectablepublicvarbottomLeft:Bool=false@IBInspectablepublicvarbottomRight:Bool=false@IBInspectablepublicvarcornerRadius:Int=0publicove

ios - 自动布局 - 如何添加 subview 以匹配 UIView 的大小?

我遇到了一个与自动布局有关的问题。我有一个设置了约束的UIView,因此它对于每个尺寸类别都处于相同的位置。我试图让我的视频完全适合此UIViewvideoViewBox。我只在iPhone6上使用它,但如果我切换到iPhone4S/5,视频将不再对齐。这是代码:varmoviePlayer:MPMoviePlayerController!@IBOutletvarvideoViewBox:UIView!overridefuncviewDidLoad(){super.viewDidLoad()letpath=NSBundle.mainBundle().pathForResource("t

ios - 如何在 Swift 3 的 UIView 上添加右边框?

我的屏幕顶部有一个UIView,我想为其添加一个1像素的右边框。这是我目前拥有的代码:varborder=CALayer()border.backgroundColor=UIColor(red:241,green:10,blue:9,alpha:1).cgColorborder.frame=CGRect(x:topView.frame.width+1,y:0,width:1,height:topView.frame.height)topView.layer.addSublayer(border)但我无法让它工作。如何为我的UIView添加右边框?提前致谢!

ios - Swift 3 和 lldb : Print frame of UIView, 给定十六进制地址

调试iOS目标、Swift3、Xcode8.2、lldb-360.1.68我想打印一个UIView的frame,我在之前的断点处获取了它的地址。这是我最好的镜头,但结果令人失望:(lldb)expr-lobjc-O--NSStringFromRect((CGRect)([(UIView*)0x7a241b30frame]))error:useofundeclaredidentifier'CGRect'谢谢! 最佳答案 如果你在快速调试器中,你可以使用unsafeBitCast将指针转换为类型。pounsafeBitCast(0x7a

swift - 为什么不应该直接扩展 UIView 或 UIViewController?

我看到了这个question,使用此代码:protocolFlashable{}extensionFlashablewhereSelf:UIView{funcflash(){UIView.animate(withDuration:0.3,delay:0,options:.curveEaseIn,animations:{self.alpha=1.0//Objectfadesin}){(animationComplete)inifanimationComplete==true{UIView.animate(withDuration:0.3,delay:2.0,options:.curveE

ios - 将 AVPlayerViewController 放在 UIView 中

目前我有一个底部有四个控件的对话View。每个控件都在对话中加载不同的View。这些控件之一是在对话View中设置一个AVPlayer并播放它。不幸的是,AVPlayer本身没有播放控件。AVPlayerViewController有播放控件。是否可以放置一个AVPlayerViewController在一个UIView中,这样它就不会作为新屏幕?我想将它放在我的UIView中,以便一切都在我的dialgoue中进行。 最佳答案 您可以初始化AVPlayerViewController并将其作为subview添加到您的ViewCon

ios - 在 Swift 中子类化 UIView - 错误

我有一个名为MyView.swift的文件,它看起来像这样:classMyView:UIView{}我还有一个MyView.xib文件,其中的View的类设置为MyView。在ViewController中我有这个:varmyView:MyView?overridefuncviewDidLoad(){super.viewDidLoad()self.myView=NSBundle.mainBundle().loadNibNamed("MyView",owner:nil,options:nil)[0]asMyViewself.myView.frame=frame;self.view.add

ios - 动画 UIView 上的动画层

我在为我的一个View中的图层设置动画时遇到问题。我用谷歌搜索了这个问题,但只能使用CATransaction找到答案,它假设我知道它的边界的fromValue和toValue。我在tableHeader中有一个View,它在单击时会自行调整大小。这个View是一个普通的UIView并且按照UIView.animate()block中的预期进行动画处理。这个View有一个CAGradientLayer作为子层,给它一个渐变的背景色。当View对其高度进行动画处理时,图层不会随之进行动画处理。动画开始时,图层会立即更改其边界。为了确保层获得正确的整体尺寸(在初始化/加载/屏幕旋转等期间)

ios - 如何以编程方式从 UIVIew 呈现 View Controller

我使用的类是MessageView(SwiftMessageLibrary)的子类,继承自UIView。在里面,我有一个UIButton,我想通过它以编程方式呈现另一个ViewController。下面是我的代码:importFoundationimportSwiftMessagesimportUIKitclassMyClass:MessageView{varhideBanner:(()->Void)?@IBActionfunchelpButtonPressed(_sender:UIButton){letstoryBoard:UIStoryboard=UIStoryboard(name

ios - 从父 UIView 移除 CALayers

有几个这样的问题,但没有一个有效的答案。我正在向UIView添加新的CALayer,如下所示:funcplaceNewPicture(){letnewPic=CALayer()newPic.contents=self.pictureDragging.contentsnewPic.frame=CGRect(x:pictureScreenFrame.origin.x-pictureScreenFrame.width/2,y:pictureScreenFrame.origin.y-pictureScreenFrame.height/2,width:pictureScreenFrame.wid