简体   繁体   English

Chameleon Framework与Swift 4不兼容吗?

[英]Chameleon Framework not compatible with Swift 4?

It appears that Chameleon Framework is not compatible with Swift 4. After successfully installing the 'ChameleonFrame/Swift' pod, I got about 30 buildtime errors. 看来Chameleon Framework与Swift 4不兼容。成功安装'ChameleonFrame / Swift'pod之后,我遇到了大约30个构建时错误。 I went ahead and fixed each error and was able to get it to work. 我继续并修复了每个错误,并使其能够正常工作。 The resulting ChameleonShorthand.swift file is posted below. 生成的ChameleonShorthand.swift文件发布在下面。 You can copy and paste it into your corresponding file. 您可以将其复制并粘贴到您的相应文件中。 If anyone has a better solution, please let me know. 如果有人有更好的解决方案,请告诉我。

import UIKit

// MARK: - UIColor Methods Shorthand

/**
Creates and returns a complementary flat color object 180 degrees away in the HSB colorspace from the specified color.

- parameter color: The color whose complementary color is being requested.

- returns: A flat UIColor object in the HSB colorspace.
*/
public func ComplementaryFlatColorOf(color: UIColor) -> UIColor {
    return UIColor(complementaryFlatColorOf: color)
}

/**
 Returns a randomly generated flat color object with an alpha value of 1.0 in either a light or dark shade.

 - parameter shade: Specifies whether the randomly generated flat color should be a light or dark shade.

 - returns: A flat UIColor object in the HSB colorspace.
 */
public func RandomFlatColorWithShade(shade: UIShadeStyle) -> UIColor {
    return UIColor(randomFlatColorOf: shade)
}

/**
 Creates and returns either a black or white color object depending on which contrasts more with a specified color.

 - parameter backgroundColor: The specified color of the contrast color that is being requested.
 - parameter returnFlat:      Pass **true** to return flat color objects.

 - returns: A UIColor object in the HSB colorspace.
 */
public func ContrastColorOf(backgroundColor: UIColor, returnFlat: Bool) -> UIColor {
    return UIColor(contrastingBlackOrWhiteColorOn: backgroundColor, isFlat: returnFlat)
}

/**
 Creates and returns a gradient as a color object with an alpha value of 1.0

 - parameter gradientStyle: Specifies the style and direction of the gradual blend between colors.
 - parameter frame:         The frame rectangle, which describes the view’s location and size in its superview’s coordinate system.
 - parameter colors:        An array of color objects used to create a gradient.

 - returns: A UIColor object using colorWithPattern.
 */
public func GradientColor(gradientStyle: UIGradientStyle, frame: CGRect, colors: [UIColor]) -> UIColor {
    return UIColor(gradientStyle: gradientStyle, withFrame: frame, andColors: colors)
}

public func HexColor(hexString: String, _ alpha: CGFloat = 1.0) -> UIColor {
    return UIColor(hexString: hexString, withAlpha: alpha)
}

/**
 Returns the average color generated by averaging the colors of a specified image.

 - parameter image: A specified UIImage.

 - returns: A flat UIColor object in the HSB colorspace.
 */
public func AverageColorFromImage(image: UIImage) -> UIColor {
    return UIColor(averageColorFrom: image)
}

// MARK: - Array Methods Shorthand

// TODO Array Extension needed ;)

/**
Generates and creates an array of 5 color objects in the HSB colorspace from the specified color.

- parameter colorSchemeType: The color scheme with which to select colors using a specified color.
- parameter color:           The specified color which the color scheme is built around.
- parameter isFlatScheme:    Pass *true* to return flat color objects.

- returns: An array of 5 color objects in the HSB colorspace.
*/
public func ColorSchemeOf(colorSchemeType:ColorScheme, color:UIColor, isFlatScheme:Bool) -> [UIColor] {
    return NSArray(ofColorsWith: colorSchemeType, using: color, withFlatScheme: isFlatScheme) as! [UIColor]
}

/**
Generates and creates an array of 5 color objects in the HSB colorspace that appear most often in a specified image.

- parameter image:          The specified image which the color scheme is built around.
- parameter withFlatScheme: Pass **true** to return flat color objects.

- returns: An array of 5 color objects in the HSB colorspace.
*/
public func ColorsFromImage(image: UIImage, withFlatScheme: Bool) -> [UIColor] {
    // TODO: Remove forced casting
    return NSArray(ofColorsFrom: image, withFlatScheme: withFlatScheme) as! [UIColor]
}


// MARK: - Special Colors Shorthand

/**
Returns a randomly generated flat color object whose alpha value is 1.0.

- returns: A flat UIColor object in the HSB colorspace.
*/
public func RandomFlatColor() -> UIColor {
    return UIColor.randomFlat()
}

public func ClearColor() -> UIColor {
    return UIColor.clear
}


// MARK: - Light Shades Shorthand

public func FlatBlack() -> UIColor {
    return UIColor.flatBlack()
}

public func FlatBlue() -> UIColor {
    return UIColor.flatBlue()
}

public func FlatBrown() -> UIColor {
    return UIColor.flatBrown()
}

public func FlatCoffee() -> UIColor {
    return UIColor.flatCoffee()
}

public func FlatForestGreen() -> UIColor {
    return UIColor.flatForestGreen()
}

public func FlatGray() -> UIColor {
    return UIColor.flatGray()
}

public func FlatGreen() -> UIColor {
    return UIColor.flatGreen()
}

public func FlatLime() -> UIColor {
    return UIColor.flatLime()
}

public func FlatMagenta() -> UIColor {
    return UIColor.flatMagenta()
}

public func FlatMaroon() -> UIColor {
    return UIColor.flatMaroon()
}

public func FlatMint() -> UIColor {
    return UIColor.flatMint()
}

public func FlatNavyBlue() -> UIColor {
    return UIColor.flatNavyBlue()
}

public func FlatOrange() -> UIColor {
    return UIColor.flatOrange()
}

public func FlatPink() -> UIColor {
    return UIColor.flatPink()
}

public func FlatPlum() -> UIColor {
    return UIColor.flatPlum()
}

public func FlatPowderBlue() -> UIColor {
    return UIColor.flatPowderBlue()
}

public func FlatPurple() -> UIColor {
    return UIColor.flatPurple()
}

public func FlatRed() -> UIColor {
    return UIColor.flatRed()
}

public func FlatSand() -> UIColor {
    return UIColor.flatSand()
}

public func FlatSkyBlue() -> UIColor {
    return UIColor.flatSkyBlue()
}

public func FlatTeal() -> UIColor {
    return UIColor.flatTeal()
}

public func FlatWatermelon() -> UIColor {
    return UIColor.flatWatermelon()
}

public func FlatWhite() -> UIColor {
    return UIColor.flatWhite()
}

public func FlatYellow() -> UIColor {
    return UIColor.flatYellow()
}

// MARK: - Chameleon - Dark Shades Shorthand

public func FlatBlackDark() -> UIColor {
    return UIColor.flatBlackColorDark() 
}

public func FlatBlueDark() -> UIColor {
    return UIColor.flatBlueColorDark() 
}

public func FlatBrownDark() -> UIColor {
    return UIColor.flatBrownColorDark() 
}

public func FlatCoffeeDark() -> UIColor {
    return UIColor.flatCoffeeColorDark() 
}

public func FlatForestGreenDark() -> UIColor {
    return UIColor.flatForestGreenColorDark() 
}

public func FlatGrayDark() -> UIColor {
    return UIColor.flatGrayColorDark() 
}

public func FlatGreenDark() -> UIColor {
    return UIColor.flatGreenColorDark() 
}

public func FlatLimeDark() -> UIColor {
    return UIColor.flatLimeColorDark() 
}

public func FlatMagentaDark() -> UIColor {
    return UIColor.flatMagentaColorDark() 
}

public func FlatMaroonDark() -> UIColor {
    return UIColor.flatMaroonColorDark() 
}

public func FlatMintDark() -> UIColor {
    return UIColor.flatMintColorDark() 
}

public func FlatNavyBlueDark() -> UIColor {
    return UIColor.flatNavyBlueColorDark() 
}

public func FlatOrangeDark() -> UIColor {
    return UIColor.flatOrangeColorDark() 
}

public func FlatPinkDark() -> UIColor {
    return UIColor.flatPinkColorDark() 
}

public func FlatPlumDark() -> UIColor {
    return UIColor.flatPlumColorDark() 
}

public func FlatPowderBlueDark() -> UIColor {
    return UIColor.flatPowderBlueColorDark() 
}

public func FlatPurpleDark() -> UIColor {
    return UIColor.flatPurpleColorDark() 
}

public func FlatRedDark() -> UIColor {
    return UIColor.flatRedColorDark() 
}

public func FlatSandDark() -> UIColor {
    return UIColor.flatSandColorDark() 
}

public func FlatSkyBlueDark() -> UIColor {
    return UIColor.flatSkyBlueColorDark() 
}

public func FlatTealDark() -> UIColor {
    return UIColor.flatTealColorDark() 
}

public func FlatWatermelonDark() -> UIColor {
    return UIColor.flatWatermelonColorDark() 
}

public func FlatWhiteDark() -> UIColor {
    return UIColor.flatWhiteColorDark() 
}

public func FlatYellowDark() -> UIColor {
    return UIColor.flatYellowColorDark() 
}

I found the solution on Chameleon Framework's Git hub page. 我在Chameleon Framework的Git中心页面上找到了解决方案。 Put this line in your Podfile: 将此行放入您的Podfile中:

pod 'ChameleonFramework/Swift', :git => 'https://github.com/ViccAlexander/Chameleon.git'

not this one: 不是这个:

pod 'ChameleonFramework/Swift'

I have seen many answers and they say to update the pod file to ChameleonFramework/Swift . 我看到了很多答案,他们说将pod文件更新为ChameleonFramework / Swift。 Actually it doesn't work as of now(It din't worked with me). 到目前为止,实际上它还不起作用(它对我不起作用)。 So if you replace the case file codes mentioned below it will work . 因此,如果替换下面提到的案例文件代码,它将起作用。 Please refer to the image file that I have attached 请参考我所附的图片文件

Just open the error of your file & replace with the codes. 只需打开文件错误并用代码替换即可。 I have commented in picture. 我已在图片中发表评论。 please see that 请看

    case kCGColorSpaceModelXYZ:
    case kCGColorSpaceModelCMYK:
    case kCGColorSpaceModelDeviceN:
    case kCGColorSpaceModelIndexed:

I found the solution on Udemy online course. 我在Udemy在线课程中找到了解决方案。 I hope this will help. 我希望这将有所帮助。 Step1: Add below code to your podfile beneath where your ruby code ends and where you installed your pods go there by terminal and type command pod update 步骤1:将以下代码添加到您的podfile中,在其下方,您的ruby代码结束,并且您通过终端将pod安装到那里,然后键入命令pod update

post_install do |installer|
        installer.pods_project.targets.each do |target|
            target.build_configurations.each do |config|
                config.build_settings['CLANG_WARN_DOCUMENTATION_COMMENTS'] = 'NO'
            end
        end
    end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM