TEL:400-8793-956
当前位置:程序、服务器

使用未解析的标识符“ kCGGradientDrawsBeforeStartLocation”

提问者: 近期获赞: 浏览人数: 发布时间:2021-03-26 09:51:20

 问:我一直遇到此错误

 
使用未解析的标识符“ kCGGradientDrawsBeforeStartLocation”
是什么原因造成的?这是代码:
 
    覆盖 func  drawRect (rect : CGRect ) { 
//绘制代码//背景视图////颜色声明let lightPurple :UIColor = UIColor (红色:0.377 ,绿色:0.075 ,蓝色:0.778 ,alpha :1.000 )let darkPurple :UIColor = UIColor (红色:0.060 ,绿色:0.036        
 
               , 蓝色: 0.202 , 阿尔法: 1.000 )
让上下文= UIGraphicsGetCurrentContext ()////梯度声明让purpleGradient = CGGradientCreateWithColors (CGColorSpaceCreateDeviceRGB (),[ lightPurple 。CGColor ,darkPurple 。CGColor ],[ 0 ,1 ])////背景图让backgroundPath = UIBezierPath (rect :
 
            CGRectMake (0 , 0 , 自我。帧。宽度, 自我。帧。高度))
CGContextSaveGState (上下文)backgroundPath 。addClip ()CGContextDrawLinearGradient (上下文,purpleGradient ,CGPointMake (160 ,0 ),CGPointMake (160 ,568 ),UInt32的(kCGGradientDrawsBeforeStartLocation        
 
            ) |  UInt32 (kCGGradientDrawsAfterEndLocation ))
CGContextRestoreGState (context )}        
    
这篇Stack Overflow帖子可能会有所帮助,但我无法理解。
 
更新
我也得到错误latitude,longitude以及navBarAttributesDictionary:
 
func  configureView () { 
//设置表格视图的bakground属性tableView 。backgroundView = BackgroundView ()//如果让navBarFont = UIFont (名称:“ HelveticaNeue-Thin” ,大小:20.0 ),则更改导航栏文本的大小和字体。{ let navBarAttributesDictionary :[ String :AnyObject ]?= [ NSForegroundColorAttributeName :UIColor 。白色        
 
                  (), NSFontAttributeName : navBarFont ] 
} navigationController ?。navigationBar 。titleTextAttributes = navBarAttributesDictionary } ^ ================这里有错误        
                                                                      
和:
 
        让 预报服务 = 预报服务(APIKey : ForecastAPIKey )
预报服务。的getForecast (纬度,长:经度){ (让目前)在^ =========== ^ =====错误这里如果让currentWeather =当前{ dispatch_async (dispatch_get_main_queue ()){如果让温度=           
 
                        currentWeather 。温度 {
自我。currentTemperatureLabel ?。如果让降水量= currentWeather,则文本= “ \(温度)º” } 。predipProbability {自我。currentPrecipitationLabel ?。文字= “雨:\(降水)%” },如果让icon = currentWeather 。图标{自我。currentWeatherIcon                         
                        ?图像 = 图标
}自我。locationLabel 。文本= “ \(自我。位置)” } } } }           
 
 
答:替换此行代码
 
UInt32 (kCGGradientDrawsBeforeStartLocation ) |  UInt32 (kCGGradientDrawsAfterEndLocation ))
CGContextRestoreGState (上下文)        
有了这个
 
[。DrawsBeforeStartLocation , 。DrawsAfterEndLocation ])
Swift 2引入了一个新的选项集类型,用于更改语法。
 
对于第二个错误,请更改此行代码
 
让 navBarAttributesDictionary : [ NSObject : AnyObject ]?
对此
 
让 navBarAttributesDictionary : [字符串: AnyObject ]?
在Swift 1.2中,API需要将字典的类型设置为[NSObject:AnyObject]。它已更改为[String:AnyObject]。         
上一篇: 我现在如何调用该函数到alert方法?
下一篇: 我如何返回两个参数并获得两个中较大的一个?