草庐IT

UIView-Encapsulated-Layout-Width

全部标签

swift - UIView 作为 subview 不会剪辑到 super View

我有一个带圆角的superView。它有一个自定义subview(UIView),它将覆盖其父View的圆角。(所以superView看起来没有圆角)我试过subview:self.clipsToBounds=true但它仍然会覆盖其父View的角落。 最佳答案 您希望剪辑在您的superView上边界。 关于swift-UIView作为subview不会剪辑到superView,我们在StackOverflow上找到一个类似的问题: https://stac

ios - 试图从 UIView 访问标签

我创建了一个.xib文件,其中有一堆标签用于SwipeView.我的问题是我不能/不知道如何在加载View后访问和更改他们的文本:letnewView=NSBundle.mainBundle().loadNibNamed("SwipeHelperView",owner:self,options:nil)[0]asUIViewfor(varsubview)innewView.subviews{if(subview.isKindOfClass(UILabel)&&subview.tag==0){subview.text="asdaS"//ERROR:cannotassign'text'in

swift - 使用 UIPanGestureRecognizer 在限定区域内拖动 UIView

我想允许用户将UIView拖动到其superView的有限区域内。尝试以下简单代码:funchandlePanForImage(recognizer:UIPanGestureRecognizer){ifletmyView=recognizer.view{switch(recognizer.state){case.Changed:lettranslation=recognizer.translationInView(self)ifinsideDraggableArea(myView.center){myView.center=CGPoint(x:recognizer.view!.cent

ios - 使用自动布局确定 UIView 的宽度 - SWIFT

好吧,在界面生成器(Main.storyboard)中,我有一个containerView:UIView嵌入到UIScrollView中。在containerView中,我想创建额外的UIView来保存内容block,例如标题、正文等。这样做的原因是这样的内容可以垂直滚动但不能水平滚动。我的目标是使用自动布局来创建这些不同的UIView。截至目前,containerView会根据所用设备的屏幕尺寸自动调整其宽度,以防止水平滚动。它使用我为宽度约束创建的IBOutlet来执行此操作。目前看起来是这样的:@IBOutletvarcontainerView:UIView!@IBOutletv

ios - 使用 Playground 在模拟器中闪烁 UIView

我正在运行Xcode6.4,玩Playground,我写了这个super基础的代码。我想在模拟器中运行代码,所以我打开了实用程序选项卡(alt-cmd-0)并选择了支票簿“[v]RuninFullSimulator”importUIKitimportXCPlaygroundleteenView=UIView(frame:CGRectMake(0,0,100,100))eenView.backgroundColor=UIColor.orangeColor()XCPShowView("View",eenView)模拟器正在显示,还有View,但是......它在闪​​烁!!(我已经尝试了很

ios - 如何允许在某些区域拖动 UIView (PanGesture ..)

我需要通过PanGestureRecognizer拖动UIView(我知道该怎么做),但我不知道如何限制它。需要从顶部填充一些,如果与设备的四个侧面之一(左、右、顶部(这里是填充)和底部)发生碰撞,则停止拖动并且您不能超过-或像顶部那样的1px填充,任何。:)我试过这个:https://github.com/andreamazz/UIView-draggable但如果我通过cagingArea设置限制区域,iPad(Air)会滞后。还有移动不流畅,我觉得原生PanGestureRecognizer最好,只需要限制区域,你知道我该怎么做吗?:)我正在用Swift编写。并且还找到了一些相关

ios - 在 UITableViewCell 中给 UIView 添加渐变

我在添加渐变图层时遇到问题,这是我的代码:overridefuncawakeFromNib(){super.awakeFromNib()letcolors:[AnyObject]=[UIColor(white:0,alpha:0.5).CGColor,UIColor(white:0,alpha:0.8).CGColor]gradientLayer.colors=colorsgradientView.layer.insertSublayer(gradientLayer,atIndex:0)}overridefunclayoutSubviews(){super.layoutSubviews

ios - 使用单个 UIView 屏蔽多个 iOS UIView

是否不能让UIView成为多个View的maskedView?我在以下UIView上设置了maskView,但只有最后一个保留了mask设置。imageOne.maskView=viewMasklabelThing.maskView=viewMasklabelOtherThing.maskView=viewMasklabelLastThing.maskView=viewMasklabelMaskThis.maskView=viewMask//theonlymaskedview为了解决这个问题,我注释掉了最后一行,并证实了我的怀疑。imageOne.maskView=viewMaskla

ios - 使用 AutoLayout 将圆角半径应用于 UIView 的顶部

我扩展了UIView以添加一个round()方法来将角半径应用到特定的角:extensionUIView{funcround(corners:UIRectCorner,radius:CGFloat)->CAShapeLayer{letpath=UIBezierPath(roundedRect:bounds,byRoundingCorners:corners,cornerRadii:CGSizeMake(radius,radius))letmask=CAShapeLayer()mask.path=path.CGPathself.layer.mask=maskreturnmask}}在一个

ios - 使用 CAShapeLayer 支持的 UIView 塑造一个三角形

从教程:http://swiftiostutorials.com/tutorial-draw-nice-triangle-view-border-cashapelayer/,我设法创建了一个三角形:classTriangle:UIView{overridefuncdrawRect(rect:CGRect){letmask=CAShapeLayer()mask.frame=self.layer.boundsletwidth=self.layer.frame.size.widthletheight=self.layer.frame.size.heightletpath=CGPathCrea