This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func drawPDFfromURL(url: URL) -> UIImage? { | |
guard let document = CGPDFDocument(url as CFURL) else { return nil } | |
guard let page = document.page(at: 1) else { return nil } | |
let pageRect = page.getBoxRect(.mediaBox) | |
let renderer = UIGraphicsImageRenderer(size: pageRect.size) | |
let img = renderer.image { ctx in | |
UIColor.white.set() | |
ctx.fill(pageRect) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (UIImage *)fixImageOrientation { | |
UIImageOrientation originOrientation = self.imageOrientation; | |
// No-op if the orientation is already correct | |
if (originOrientation == UIImageOrientationUp) return self; | |
// We need to calculate the proper transformation to make the image upright. | |
// We do it in 2 steps: Rotate if Left/Right/Down, and then flip if Mirrored. | |
CGAffineTransform transform = CGAffineTransformIdentity; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 直接翻转UIImageView | |
func flipImageView(imageView: UIView) { | |
imageView.transform = CGAffineTransform(scaleX: -1, y: 1) | |
} | |
// 修改imageOrientation属性, 这个方法只适用于UIKit中显示的image | |
func flipImage(originImage: UIImage) -> UImage { | |
let cgImage = originImage.cgImage! | |
let flipedImage = UIImage(cgImage: originImage, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// show image | |
self.imageView.image = [UIImage imageNamed:@"imagename"]; | |
// create effect | |
UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]; | |
// add effect to an effect view | |
UIVisualEffectView *effectView = [[UIVisualEffectView alloc]initWithEffect:blur]; | |
effectView.frame = self.view.frame; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)removeFile:(NSString *)filename | |
{ | |
NSFileManager *fileManager = [NSFileManager defaultManager]; | |
NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; | |
NSString *filePath = [documentsPath stringByAppendingPathComponent:filename]; | |
NSError *error; | |
BOOL success = [fileManager removeItemAtPath:filePath error:&error]; | |
if (success) { | |
UIAlertView *removedSuccessFullyAlert = [[UIAlertView alloc] initWithTitle:@"Congratulations:" message:@"Successfully removed" delegate:self cancelButtonTitle:@"Close" otherButtonTitles:nil]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSString *)jsonFromDictionary:(NSDictionary *)dict { | |
NSDictionary *plistDict = nil; | |
if (dict != nil) { | |
plistDict = dict; | |
}else { | |
NSString *path = [[NSBundle mainBundle] pathForResource:@"items.plist" ofType:nil]; | |
NSArray *array = [NSArray arrayWithContentsOfFile:path]; | |
plistDict = [NSDictionary dictionaryWithObject:array forKey:@"list"]; | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#import <Social/Social.h> | |
#import <Accounts/Accounts.h> | |
typedef void(^VideoUploadCompletion)(BOOL success, NSString *errorMessage); | |
typedef void(^ResultAccount)(ACAccount *account); | |
@interface SocialVideoHelper : NSObject | |
+(void)getFirstTwitterAccount:(ResultAccount)complete; |