I got a swift category for UIImage, but I can't figure out how to make it work.
This is the swift category i'm trying to use:
import UIKit
extension UIImage {
func imageWithColor(color1: UIColor) -> UIImage {
UIGraphicsBeginImageContextWithOptions(self.size, false, self.scale)
color1.setFill()
let context = UIGraphicsGetCurrentContext()! as CGContextRef
CGContextTranslateCTM(context, 0, self.size.height)
CGContextScaleCTM(context, 1.0, -1.0);
CGContextSetBlendMode(context, CGBlendMode.Normal)
let rect = CGRectMake(0, 0, self.size.width, self.size.height) as CGRect
CGContextClipToMask(context, rect, self.CGImage)
CGContextFillRect(context, rect)
let newImage = UIGraphicsGetImageFromCurrentImageContext() as UIImage
UIGraphicsEndImageContext()
return newImage
}
}
In my objective C View Controller code I Tried to import:
#import "UIImage+Overlay.swift"
And xcode gives me a lot of errors, it's looks like Objective C errors. It seems it doesn't understand swift code.
Errors: unexpected '@' in program when I declare the first property:
@property (nonatomic, strong) NSArray *contentImages;
As suggested by Leo Natan, I did try to import, but I think is because the name of my App. I did try all this kind of import, but still saying can't find it.
#import <ProductName/ProductModuleName-Swift.h>
#import <Say_Cheese_/Say_Cheese_-Swift.h>
#import <Say Cheese!/Say_Cheese_-Swift.h>
#import <Say Cheese!-Say_Cheese_-Swift.h>
#import <Say Cheese!-Bridging-Header.h>
My Product Name is "Say Cheese!" My Product Module Name is Say_Cheese_, but behind is $(PRODUCT_NAME:c99extidentifier)
I'm afraid to change the Product Module Name, is it safe?