Показаны сообщения с ярлыком Tips&Tricks. Показать все сообщения
Показаны сообщения с ярлыком Tips&Tricks. Показать все сообщения

3 апр. 2015 г.

24 мар. 2015 г.

UIButton popup анимация / UIButton popup animation

Анимация кнопки (UIButton) по клику или без. Также можно анимировать любой другой контрол.








button.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.001, 0.001);
    [self.view addSubview:button];
    
    [UIView animateWithDuration:0.4/1.5 animations:^{
        button.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.3, 1.3);
    } completion:^(BOOL finished) {
        [UIView animateWithDuration:0.4/2 animations:^{
            button.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.8, 0.8);
        } completion:^(BOOL finished) {
            [UIView animateWithDuration:0.4/2 animations:^{
                button.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.1, 1.1);
            } completion:^(BOOL finished) {
                [UIView animateWithDuration:0.4/2 animations:^{
                    button.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.0, 1.0);
                } completion:^(BOOL finished) {
                    button.transform = CGAffineTransformIdentity;
                }];
            }];
        }];

    }];

21 мар. 2015 г.

Beginning Xcode. Swift Edition

Beginning Xcode, Swift Edition will not only get you up and running with Apple’s latest version of Xcode, but it also shows you how to use Swift in Xcode and includes a variety of projects to build.
If you already have some programming experience with iOS SDK and Objective-C, but want a more in-depth tutorial on Xcode, especially Xcode with Apple’s new programming language, Swift, then Beginning Xcode, Swift Edition is for you. The book focuses on the new technologies, tools and features that Apple has bundled into the new Xcode 6, to complement the latest iOS 8 SDK.
By the end of this book, you’ll have all of the skills and a variety of examples to draft from to get your Swift app from idea to App Store with all the power of Xcode.
What you’ll learn
How to use Swift and new Swift-related features in Xcode
How to get started with Xcode, using Workspaces, Interface Builder, storyboarding, tables/collection views and more
How to dive deeper into Xcode using advanced searches, filtering, advanced editing, debugging, and source control
How to take advantage of Xcode’s vast libraries, frameworks and bundles
How to create exciting interactive apps for iPhone or iPad using Sprite Kit, Map Kit, and other Apple technologies
How to share your app using organizer, localization, auto layout, and more
Who this book is for
This book is for those with some Objective-C/Cocoa and/or iOS SDK app development experience, but want to be more efficient in writing and testing their code, and people who want to know in-depth examples of Swift in Xcode.

Название: Beginning Xcode. Swift Edition
Автор: Knott M.
Год: 2014
Издательство: Apress
ISBN: 978-1-4842-0538-9
Страниц: 544
Язык: Английский
Формат: PDF
Размер: 31 Mb

20 мар. 2015 г.

Swift Quick Syntax Reference

Swift Quick Syntax Reference is a condensed code and syntax reference to the new Apple Swift programming language, which is the alternative new programming language along side Objective-C behind the APIs found in the Apple iOS SDK 8 and OS X Yosemite SDK. It presents the essential Swift syntax in a well-organized format that can be used as a handy reference.

You won't find any technical jargon, bloated samples, drawn out history lessons, or witty stories in this book. What you will find is a language reference that is concise, to the point, and highly accessible. The book is packed with useful information and is a must-have for any Swift programmer.




Publisher: Apress
By: Matthew Campbell
ISBN: 978-1-484204-40-5
Year: 2014
Pages: 180
Language: English
File size: 4.6 MB
File format: PDF

Pro Design Patterns in Swift

The Swift programming language has transformed the world of iOS development and started a new age of modern Cocoa development. Pro Design Patterns in Swift shows you how to harness the power and flexibility of Swift to apply the most important and enduring design patterns to your applications, taking your development projects to master level.

This book will teach you those design patterns that have always been present at some level in your code, but may not have been recognized, acknowledged, or fully utilized. Implementation of specific pattern approaches will prove their value to any Swift developer.

Best-selling author Adam Freeman explains how to get the most from design patterns. He starts with the nuts-and-bolts and shows you everything through to advanced features, going in-depth to give you the knowledge you need.

Publisher: Apress
By: Adam Freeman
ISBN: 978-1-484203-95-8
Year: 2015
Pages: 592
Language: English
File size: 7.5 MB
File format: PDF

Swift for Absolute Beginners

The professional development team that brought you two editions of Objective-C for the Absolute Beginners and have taught thousands of developers around the world to write some of the most popular iPhone apps in their categories on the app store, have now leveraged their instruction for Swift.

Swift for Absolute Beginners is perfect for those with no programming background, those with some programming experience but no object-oriented experience, or those that have a great idea for an app but haven't programmed since school.

Gary Bennett and Brad Lees are full-time professional iOS developers and have developed a broad spectrum of apps for Fortune 500 companies. The authors have taken their combined 12 years of writing apps, teaching online iOS courses, the experience from their first two iOS books, along with their free online instruction and free online forum to create an excellent training book.


Publisher: Apress
By: Gary Bennett, Brad Lees
ISBN: 978-1-484208-87-8
Year: 2014
Pages: 308
Language: English
File size: 16.3 MB
File format: PDF

19 мар. 2015 г.

Анимация UITextField, проверка на число / UITextField not number animation

Проверка UITextField на числовой тип (float) и простая анимация если введенные данные не являются таковыми.




// Проверка введенных данных на числовую форму

- (void)textIsValidValue:(NSString *)text textField:(UITextField *)textField {
    
    BOOL result = NO;
    NSScanner *scanner = [NSScanner scannerWithString:text];
    
    if (!(result = [scanner scanFloat:NULL] && [scanner isAtEnd])) {
        
        _isWrongText = YES;
        [self animateTextFieldOnError:textField];
    
    } else { _isWrongText = NO; }

}


// Анимация поля и смена цвета текста если обнаружена ошибка

- (void)animateTextFieldOnError:(UITextField *)textField {
    
    CAKeyframeAnimation * anim = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
    anim.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeTranslation(-10.0f, 0.0f, 0.0f)],
                    [NSValue valueWithCATransform3D:CATransform3DMakeTranslation(10.0f, 0.0f, 0.0f)]];
    anim.autoreverses = YES;
    anim.repeatCount = 2.0f;
    anim.duration = 0.1f;
    
    [textField.layer addAnimation:anim forKey:nil];
    textField.textColor = [UIColor redColor];
}

18 мар. 2015 г.

11 мар. 2015 г.

8 мар. 2015 г.

Удаление / замена ненужных символов в строке


Иногда нам нужно избавиться от ненужных символов в строке, так как они могут помешать нам что либо реализовать. Например ответ от сервера с не отформатированным JSON`ом, ключи и значения которого просто разделены запятыми. По запятым мы строку разбить можем, а дальше у нас в подстроках присутствует JSON`овский мусор ( {[ключ:значение] ).
Почистить строку довольно просто (например я использую данную функцию чтобы преобразовать запятую в точку, когда пользователь вводит число с плавающей точкой с русской раскладкой):

// Смена запятой в числе на точку

- (NSString *)replacePriceCountToDotCharacter:(NSString *)string {
    
    NSCharacterSet *charactersToRemove = [NSCharacterSet characterSetWithCharactersInString:@","];
    NSString *trimmedReplacement = [[string componentsSeparatedByCharactersInSet:charactersToRemove]
                                    componentsJoinedByString:@"."];
    
    return trimmedReplacement;

}

Вместо запятой можно прописать любые символы (не разделяя никакими пробелами или запятыми) которые нужно удалить или заменить (вместо точки) на другие. Для простого удаления достаточно убрать точку и оставить строку пустой ( @"" ).

23 февр. 2015 г.

22 февр. 2015 г.

19 февр. 2015 г.

Xcode. Синхронизация ваших сниппетов.

Во время разработки приложений очень часто приходится писать один и тот же код или реализацию какого-нибудь алгоритма (взять тот же банальный rootViewController). Чтобы тратить меньше времени на написание монотомного кода создаю сниппеты.

Через некоторое время стал вопрос (т.к. иногда приходится брать работу на дом, да и не отставать в своих проектах) - КАК синхронизировать свои сниппеты с "домашней" средой разработки и наоборот.

Перелопатив кучу интернет-ресурсов и информации толком так ничего и не нашел. Но вопрос оставался открытым, уже выкинул из головы эту тему, НО, тут на днях по некоторой воли "случайности" наткнулся на зарубежную статью. Решение синхронизации между IDE оказалось довольно простым (все телодвижения проводим в терминале):

$ cd ~/Library/Developer/Xcode/UserData
$ mv CodeSnippets /Dropbox/Xcode/
$ ln -s ~/Dropbox/Xcode/CodeSnippets/ CodeSnippets

Логично использовать, вместо Dropbox, свой любимый облачный сервис.
Главное что стоит помнить - Данные манипуляции проводятся только на одной стороне. На другой стороне нужны только первая и третья строчки, не забыв перед этим удалить папку CodeSnippets, а потом уж создавать симлинк на папку в Dropbox`е.

18 февр. 2015 г.