草庐IT

ios - 特殊阴影 : Swift 2

在下图中,我有两种类型的阴影。在swift中,我使用了这个函数:funcapplyShadow(view:UIView){view.layer.shadowColor=UIColor.blackColor().CGColorview.layer.shadowOffset=CGSizeMake(0,1)view.layer.shadowOpacity=0.5view.layer.shadowRadius=10.0view.clipsToBounds=falseview.layer.masksToBounds=false}将阴影应用于ImageView中的图像。如何修改applyShado

ios: 我想在 tableview 的顶部和底部添加边框

ihaveappliedbelowcodeinviewdidload()butusingthiscodeborderisarrivebutitscrollingwithtablecontent.iwantfixborderattopandbottomside.heremycodeis->lettopBorder=CAShapeLayer()lettopPath=UIBezierPath()topPath.move(to:CGPoint(x:0,y:0))topPath.addLine(to:CGPoint(x:tblFilter.frame.width,y:0))topBorder.p

ios - ImageView 的圆底线

我只希望我的imageView的底部边框是圆形的。我如何以编程方式执行此操作?感谢您的帮助! 最佳答案 您可以通过子类化UIImageView来做到这一点:importUIKitclassCustomImageView:UIImageView{overridepublicfunclayoutSubviews(){super.layoutSubviews()self.roundUpCorners([.bottomLeft,.bottomRight],radius:30)}}extensionUIView{funcroundUpCorn

ios - 为什么 UITextField 不允许我添加边框颜色?

我有下面的方法,它应该向uitextfield添加边框颜色,但由于某种原因,它没有添加边框颜色,尽管它确实成功地添加到可以输入的View中。funcsetupSearchBar(){searchField.frame=CGRect(x:4,y:6.5,width:366.58,height:42)searchField.layer.cornerRadius=searchField.frame.height/2topBackgroundView.layer.borderWidth=0.35searchField.layer.borderColor=UIColor(red:0/225,gr

ios - 在 UIView Swift 中居中 CAShapeLayer

我无法在UIView中将CAShapeLayer居中。我搜索过,大多数解决方案来自2015年前的ObjC或尚未解决。附件是图片的样子。当我检查它时,它在红色View内,但我不知道为什么它不居中。我试过调整它的大小,但仍然不起作用。letprogressView:UIView={letview=UIView()view.backgroundColor=.redreturnview}()//MARK:-ViewDidLoadoverridefuncviewDidLoad(){super.viewDidLoad()view.addSubview(progressView)progressVi

ios - 使用 CGPaths 和 CAShapeLayers 动画绘制字母

我目前正在使用这段代码来为角色绘制动画:varpath=UIBezierPath()varunichars=[UniChar]("J".utf16)varglyphs=[CGGlyph](count:unichars.count,repeatedValue:0)letgotGlyphs=CTFontGetGlyphsForCharacters(font,&unichars,&glyphs,unichars.count)ifgotGlyphs{letcgpath=CTFontCreatePathForGlyph(font,glyphs[0],nil)path=UIBezierPath(C

ios - 在 UIView 类中添加 UIView 舍入逻辑

我有一个自定义的UIView,我将它添加到我的ViewController中,如下所示:letmyCustomView=Bundle.main.loadNibNamed("MyCustomView",owner:nil,options:nil)as!MyCustomViewmyCustomView.layer.cornerRadius=10myCustomView.layer.masksToBounds=true我绕过View的角落。但我想知道,有没有办法在MyCustomView类中移动这种圆角逻辑? 最佳答案 当你使用IB时,你

swift - 为 UIColor 创建自定义颜色

我有一个关于在swift中创建自定义UIColor的问题。我使用了以下扩展代码:importUIKitextensionUIColor{convenienceinit(red:Int,green:Int,blue:Int){letnewRed=CGFloat(red)/255letnewGreen=CGFloat(green)/255letnewBlue=CGFloat(blue)/255self.init(red:newRed,green:newGreen,blue:newBlue,alpha:1.0)}}letbrandBlue=UIColor(red:0,green:127,bl

ios - CAShapeLayer mask 从底部显示

我正在尝试从图像底部创建“显示”效果。我认为这就像将anchorPoint设置为CGPointMake(0.5,1.0)或将contentsGravity设置为kCAGravityTop一样简单,但这些选项都不起作用。我的当前代码有效,但从上到下进行动画处理。这是揭示的想法:http://giphy.com/gifs/xTiTnBzItdgaD1xHMc我如何使它从下到上进行?这是代码letpath=UIBezierPath(rect:CGRectMake(0,0,imgEmptyBase.width,imgEmptyBase.height-80))letmask=CAShapeLay

ios - 阴影未出现在 UIImageView 下(Swift)

我编写了以下代码来下载图像并将其显示在tableView的单元格中。但是,投影根本没有出现,我不知道出了什么问题。cell.societyImage.setIndicatorStyle(UIActivityIndicatorViewStyle.White)cell.societyImage.setShowActivityIndicatorView(true)cell.societyImage.sd_setImageWithURL(NSURL(string:pictureURLs[objectIds[indexPath.row]]!),completed:{(image,error,ca