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
| extension UIImage { | |
| private static let defaultThumbSize = CGSize(width: 640, height: 480) | |
| func generatePreview() -> Data? { | |
| guard let imageData = UIImageJPEGRepresentation(self, 0.5) else { return nil } | |
| guard let imageSource = CGImageSourceCreateWithData(imageData as CFData, nil) else { return nil } | |
| guard let properties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, nil) as? Dictionary<String, Any> else { return nil } | |
| guard let width = properties[kCGImagePropertyPixelWidth as String] as? Float else { return nil } | |
| guard let height = properties[kCGImagePropertyPixelHeight as String] as? Float else { return 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
| /*Im Macros*/ | |
| #define LocalizedString(key, comment) [LanguageUtils getLocalizedStringForKey:(key)] | |
| /*In Language Utils class*/ | |
| + (NSString *)getLocalizedStringForKey:(NSString *)key { | |
| NSString *oldLocalization = [NSBundle.mainBundle localizedStringForKey:(key) value:@"" table:nil]; | |
| if (oldLocalization.length > 0) { | |
| return oldLocalization; | |
| } |
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
| /// Returns an appropriate size for page thumbnails. | |
| /// | |
| /// - Parameters: | |
| /// - pageSize: The page size. Only the aspect ratio is considered, so the units are irrelevant. | |
| /// - containerSize: The size of the container that will display the thumbnails in points. | |
| /// - interitemSpacing: The padding between thumbnails in points. | |
| /// - Returns: An appropriate size for thumbnails in points. | |
| func automaticThumbnailSize(for pageSize: CGSize, containerSize: CGSize, interitemSpacing: CGFloat) -> CGSize { | |
| // What is the total available area? | |
| let containerArea = containerSize.width * containerSize.height |
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 didTapAttributedText(inLabel label: UILabel?, andInRange range: NSRange?) -> Bool { | |
| guard let range = range, let label = label else { | |
| return false | |
| } | |
| // Create instances of NSLayoutManager, NSTextContainer and NSTextStorage | |
| let layoutManager = NSLayoutManager() | |
| let textContainer = NSTextContainer(size: label.bounds.size) | |
| let textStorage = NSTextStorage(attributedString: label.attributedText!) | |
| // Configure layoutManager and textStorage |
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 UIKit | |
| class AZTextFrameAttributes: NSObject { | |
| // MARK: - Properties | |
| fileprivate(set) var width: CGFloat = 0 | |
| fileprivate(set) var string: String? | |
| fileprivate(set) var attributedString: NSAttributedString? | |
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
| ios-channels.ru | |
| digest.mbltdev.ru | |
| bit.ly/podlodka_podcast | |
| vk.com/iosdevcourse | |
| iosgoodreads.ru | |
| vk.com/iosninja | |
| peerlab.community | |
| cocoadevelopers.club |
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 *strCurrentDate; | |
| NSString *strNewDate; | |
| NSDate *date = [NSDate date]; | |
| NSDateFormatter *df =[[NSDateFormatter alloc]init]; | |
| [df setDateStyle:NSDateFormatterMediumStyle]; | |
| [df setTimeStyle:NSDateFormatterMediumStyle]; | |
| strCurrentDate = [df stringFromDate:date]; | |
| NSLog(@"Current Date and Time: %@",strCurrentDate); | |
| int hoursToAdd = 3; | |
| NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; |
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
| #pragma mark - UIViewControllerAnimatedTransitioning | |
| - (NSTimeInterval)transitionDuration:(nullable id <UIViewControllerContextTransitioning>)transitionContext { | |
| return 0.4; | |
| } | |
| - (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext { | |
| UIView *fromView = [transitionContext viewForKey:UITransitionContextFromViewKey]; | |
| UIView *toView = [transitionContext viewForKey:UITransitionContextToViewKey]; | |
| UIView *container = [transitionContext containerView]; | |
| CGAffineTransform transform = CGAffineTransformMakeScale(0.01, 0.01); |
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 cropedImage(image:UIImage, withFrame frame: CGRect) -> UIImage { | |
| //create drawing context | |
| UIGraphicsBeginImageContextWithOptions(frame.size, false, 0.0) | |
| let context: CGContext? = UIGraphicsGetCurrentContext() | |
| // context?.translateBy(x: frame.size.width, y: frame.size.height) | |
| // // Rotate the image context | |
| //draw | |
| // context?.translateBy(x: -0.5 * frame.size.width, y: -0.5 * frame.size.height) | |
| image.draw(in: CGRect(x: -frame.origin.x, y: -frame.origin.y, width: image.size.width, height: image.size.height)) | |
| //capture resultant image |
NewerOlder