SlideShare a Scribd company logo
1 of 89
Download to read offline
iOS 7 SDK
彼得潘
•
•
• :App -
iPhone . iPad
•
2012
Top 6
App
APP
Mac
http://www.facebook.com/iphone.peterpan
http://deeploveapple.blogspot.tw
apppeterpan@gmail.com
http://apppeterpan.blogspot.tw
FB
blog
wiki
http://peterpan.uservoice.com
http://deeploveiossdk.tumblr.com
wiki
email
agenda
• iOS 7 SDK
• Xcode 5
• Objective-C Foundation framework
• iOS 6 App iOS 7 (UI )
•
• 1: Motion Effects (3D)
• 2: UIKit Dynamics (2D)
iOS 7 SDK
• UI
•
•
•
• device
•
•
•
•
• device
• App
• JavaScript
• iBeacon
• Machine Readable
Code Detection
• Apple Map
• Safari Reading list
•
UI
• UI
• Button
• nav bar search bar
• blurred background ( )
• image rendering mode (App iOS 7 )
• tint color (App iOS 7 )
• full screen status bar &
navigation bar (App iOS 7 )
UI
button
nav bar search bar
UISearchBar *searchBar = [[UISearchBar alloc] init];
searchController = [[UISearchDisplayController alloc]
initWithSearchBar:searchBar contentsController:self];
searchController.searchResultsDataSource = self;
searchController.searchResultsDelegate = self;
searchController.delegate = self;
searchController.displaysSearchBarInNavigationBar = YES;
searchController.navigationItem.rightBarButtonItem =
[[UIBarButtonItem alloc] initWithTitle:@"Close"
style:UIBarButtonItemStylePlain target:self
action:@selector(close:)];
UISearchDisplayController.h
@property (nonatomic, assign) BOOL
displaysSearchBarInNavigationBar;
UINavigationController UINavigationBar
blurred background
( )
https://developer.apple.com/downloads/index.action
UIImage+ImageEffects
- (UIImage *)applyBlurWithRadius:(CGFloat)blurRadius tintColor:(UIColor *)tintColor
saturationDeltaFactor:(CGFloat)saturationDeltaFactor maskImage:(UIImage
*)maskImage;
UIToolbar
- (void)viewDidLoad
{
[super viewDidLoad];
!
UIScrollView *scrollView = [[UIScrollView alloc]
initWithFrame:CGRectMake(0, 20, 320, 320)];
[self.view addSubview:scrollView];
scrollView.contentSize = CGSizeMake(320, 1000);
UIImageView *imageView = [[UIImageView alloc]
initWithFrame:CGRectMake(0, 0, 320, 1000)];
imageView.image = [UIImage imageNamed:@"cute.jpg"];
[scrollView addSubview:imageView];
UIToolbar *toolBar = [[UIToolbar alloc]
initWithFrame:CGRectMake(0, 20, 320, 44)];
[self.view addSubview:toolBar];
}
UIToolbar
UIToolbar *toolBar = [[UIToolbar alloc]
initWithFrame:CGRectMake(0, 20, 320,
44)];
[self.view addSubview:toolBar];
toolBar.barTintColor = [UIColor blueColor];
• view controller
• CollectionView
• interactive transition
• Motion Effects ( )
• UIKit Dynamics ( )
view controller
http://www.doubleencore.com/2013/09/ios-7-custom-transitions
http://www.appdesignvault.com/custom-transition-ios-7
http://blog.bignerdranch.com/3871-golden-opportunity-custom-
transitions/
UIViewControllerAnimatedTransitioning protocol
CollectionView
WWDC 2013 Sample: iOS_CollectionViewTransition
ex: App YearsView Collections zoom in
https://developer.apple.com/downloads/index.action?name=WWDC%202013
interactive transition
• controller
• ex: scroll
UIViewControllerInteractiveTransitioning
Multitasking Enhancements
• (Background Fetch)
• ( Remote Notification )
silent push
( )
App
Remote Notification
Text Kit
Letterpress ( )
Letterpress Letterpress
letterpress
UILabel *label = [[UILabel alloc]
initWithFrame:CGRectMake(0, 0, 320, 320)];
label.font = [UIFont systemFontOfSize:150];
label.textAlignment = NSTextAlignmentCenter;
NSDictionary *attrDic =
@{NSForegroundColorAttributeName : [UIColor
colorWithRed:0 green:0 blue:1 alpha:0.5],
NSTextEffectAttributeName :
NSTextEffectLetterpressStyle};
NSAttributedString *attrString = [[NSAttributedString
alloc] initWithString:@" " attributes:attrDic];
label.attributedText = attrString;
[self.view addSubview:label];
NSAttributedString.h
UIKIT_EXTERN NSString *const NSTextEffectLetterpressStyle
NS_AVAILABLE_IOS(7_0);
Exclusion paths
Exclusion paths
UITextView *textView = [[UITextView alloc]
initWithFrame:CGRectMake(0, 40, 320, 400)];
textView.backgroundColor = [UIColor clearColor];
textView.textColor = [UIColor whiteColor];
textView.text = @"
";
textView.font = [UIFont systemFontOfSize:28];
UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(10.0, 40.0)];
[path addLineToPoint:CGPointMake(110.0, 140.0)];
[path addLineToPoint:CGPointMake(210, 40)];
[path closePath];
textView.textContainer.exclusionPaths = @[path];
[self.view addSubview:textView];
NSTextContainer.h
@property(copy, NS_NONATOMIC_IOSONLY) NSArray *exclusionPaths;
Text attachments
Text attachments
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(0,
40, 320, 400)];
textView.backgroundColor = [UIColor clearColor];
NSMutableAttributedString *str = [[NSMutableAttributedString alloc]
initWithString:@"
"];
NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
attachment.image = [UIImage imageNamed:@"shoppingIcon.png"];
[str appendAttributedString:[NSAttributedString
attributedStringWithAttachment:attachment]];
[str appendAttributedString:[[NSMutableAttributedString alloc]
initWithString:@"
"]];
textView.attributedText = str;
[self.view addSubview:textView];
NSTextAttachment.h
@interface NSAttributedString (NSAttributedStringAttachmentConveniences)
// A convenience method for creating an attributed string containing
attachment using NSAttachmentCharacter as the base character.
+ (NSAttributedString *)attributedStringWithAttachment:(NSTextAttachment
*)attachment NS_AVAILABLE_IOS(7_0);
@end
dynamic text size
AirDrop
available on iPhone 5, iPad (4th generation), iPad mini, and iPod touch (5th generation)
requires an iCloud account
:Wifi Bluetooth
AirDrop
• UIActivityViewController
• Share
• NSString & NSAttributedString ( Notes.app )
• UIImage & AVAsset (Photos.app )
• NSURL
• Safari.app
• App
Machine Readable
Code Detection
support barcode
• QR code
• Aztec
• EAN13
• EAN8
• UPC-E
• PDF417
• Code 93
• Code 39
• Code 39 mod 43
AVCaptureMetadataOutput
SSReadingList
Safari Reading list
NSURL *url = [NSURL URLWithString:@"https:/
/www.facebook.com/iphone.peterpan"];
[[SSReadingList defaultReadingList]
addReadingListItemWithURL:url title:@" "
previewText:@" " error:nil];
• CIDetectorSmile
• CIDetectorEyeBlink
Multipeer Connectivity
• device
• :
infrastructure Wi-Fi networks
peer-to-peer Wi-Fi
Bluetooth
Multipeer Connectivity
Inter-App Audio
• App MIDI
• App
iBeacon
bluetooth
beacon : iPhone
CLBeaconRegion
Map Kit
MKOverlayRenderer
overlay
MKOverlayRenderer
Direction
AVSpeechSynthesis
AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc]
init];
AVSpeechUtterance *utterance = [AVSpeechUtterance
speechUtteranceWithString:@" "];
[synthesizer speakUtterance:utterance];
AVSpeechSynthesizer
AVSpeechSynthesizer:
• M7
• 5s support
• CMStepCounter
• typedef void (^CMStepUpdateHandler)(NSInteger
numberOfSteps, NSDate *timestamp, NSError
*error);
Sprite Kit
• OpenGL ES
• library Cocos 2D
• 2D
Game Controller
: Bluetooth
Game Controller
Game Controller
JavaScriptCore
• objective-c javascript
• javascript objective-c
Xcode 5
Xcode 5
• UI
•
• Asset Catalogs
• Image Slicing
•
• App
• Interface Builder Preview
• support 64 bit iOS (iPhone 5s)
•
• App Capability
• Debug Gauges
• XCTest
• Continuous Integration
• Autolayout
• Quick Look
•
Xcode
• OS X Mavericks
template
Asset Catalogs &
Image Slicing
•
•
ex: @2x, ~ipad
•
• App Icon
branch
branch
Debug Gauges
App
App Capability
Management
Quick Look debug
Preview
Preview
/**
sing a song
@code
ViewController controller = [ViewController alloc] init];
[controller singSong:@" 89 "];
@endcode
@see http://www.apple.com for more info
@param song
the song to sing
@return YES if song name lenght > 3
*/
-(BOOL)singSong:(NSString*)song
{
if (song.length > 3)
{
return YES;
}
else
{
return NO;
}
}
IB auto layout
• IB constraint
• constraint
XCTest
Continuous Integration
• build App
• simulator
• OS X Mavericks Server
•
•
• on commit
• periodically
Continuous Integration
Objective-C
Foundation framework
Objective-C
Foundation framework
• module
• instancetype
• NSArray
module
• SDK framework
•
• import
framework
module
: MapKit.framework
module
!
@import
• @import QuartzCore;
• @import QuartzCore.CoreAnimation;
• #import @import
ex:
(1) #import <UIKit/UIKit.h>
@import UIKit;
(2) #import <iAd/ADBannerView.h>
@import iAd.ADBannerView;
• module
#import
enable modules
instancetype
id
NSArray.h
+ (id)array;
NSDictionary *dic = [NSArray array];
instancetype
NSArray.h
+ (instancetype)array;
return type
array
NSArray.h
- (id)firstObject NS_AVAILABLE(10_6, 4_0);
- (id)lastObject;
firstObject iOS 7
NSArray *array = [[NSArray alloc] init];
NSLog(@"array %@", array[0]);
NSArray *array = [[NSArray alloc] init];
NSLog(@"array %@", [array firstObject]);
nil
iOS 6 App iOS 7
iOS 7 iOS 6
iOS 6 App iOS 7
• App Icon
• Asset Catalogs Image Slicing
• tint color
• iOS
• full screen status bar &
navigation bar
• image render mode
• interactivePopGestureRecognizer
• keyboard , picker & alert view
App Icon size
App Icon (pixel)
iPhone 57 * 57
iPhone Retina 114 * 114
iPad (iPad mini) 72 * 72
iPad Retina 144 * 144
iPhone Retina iOS 7 120 * 120
iPad (iPad mini) iOS 7 76 * 76
iPad Retina iOS 7 152 * 152
iOS 7
Retina
App iPhone App iOS 7
-> retina
size
Launch Image (pixel)
iPhone 3.5 320 * 480
iPhone Retina 3.5 640 * 960
iPhone Retina 4 640 * 1136
iPad (iPad mini) 768 * 1024
1024 * 768
iPad Retina 1536 * 2048
2048 * 1536
full screen status bar
App Icon
asset catalogs Use Asset Catalog
asset catalogs
asset catalogs
image.xcassets AppIcon
iOS AppIcon
attributes inspectorps: Development Target
• support png
•
•
Asset Catalogs
andy.png tony.png
self.imageView.image = [UIImage imageNamed:@"handsome"];
Asset Catalogs
andy.png tony.png chilam.png tai.pnglin.png
Image Slicing
tint color
tint color
• UI
• active UI tab
• UI (ex: UIButton )
• button
UIView tintColor property
• default: blue
• tintColor :
1.
2. superview
tintColor superview
3. superview tintColor
• App
1. UI tint color
2. App tint color
UIView.h
@property(nonatomic,retain) UIColor *tintColor NS_AVAILABLE_IOS(7_0);
view superview tintColor
App tint color
• window tintColor
• storyboard global tint
tint color
self.view.tintColor = [UIColor orangeColor];
iOS 6 Crash
tintColor property iOS 7
iOS
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1)
{
}
else
{
}
NSObjCRuntime.h
#define NSFoundationVersionNumber_iPhoneOS_2_0!678.24
#define NSFoundationVersionNumber_iPhoneOS_2_1 678.26
#define NSFoundationVersionNumber_iPhoneOS_2_2 678.29
#define NSFoundationVersionNumber_iPhoneOS_3_0 678.47
#define NSFoundationVersionNumber_iPhoneOS_3_1 678.51
#define NSFoundationVersionNumber_iPhoneOS_3_2 678.60
#define NSFoundationVersionNumber_iOS_4_0 751.32
#define NSFoundationVersionNumber_iOS_4_1 751.37
#define NSFoundationVersionNumber_iOS_4_2 751.49
#define NSFoundationVersionNumber_iOS_4_3 751.49
#define NSFoundationVersionNumber_iOS_5_0 881.00
#define NSFoundationVersionNumber_iOS_5_1 890.10
#define NSFoundationVersionNumber_iOS_6_0 993.00
#define NSFoundationVersionNumber_iOS_6_1 993.00
iOS SDK: crash
iOS deprecated SDK: do nothing
iOS 6 tintColor
UINavigationBar.h
@property(nonatomic,retain) UIColor *tintColor;
@property(nonatomic,retain) UIColor *barTintColor NS_AVAILABLE_IOS(7_0)
UI_APPEARANCE_SELECTOR;
iOS 7 barTintColor
full screen
status bar
navigation bar
cell:
UITableViewStyleGrouped
view controller’s view size
• iOS 7 view size full
screen
• iOS 6 view size full screen
• status bar black translucent
• controller wantsFullScreenLayout
YES
• navigation bar translucent YES
controller
320 * 568
nav bar & tab bar
nav bar controller
controller tab bar
( 519 = 568 - 49)
Extend Edges
bar translucent
nva bar translucent Under Top bars
tab bar translucent Under Bottom bars
Under Opaque Bars
bar
455 = 568 - 20 - 44 -49
UIViewController.h
@property(nonatomic,assign) UIRectEdge edgesForExtendedLayout;
@property(nonatomic,assign) BOOL extendedLayoutIncludesOpaqueBars;
UIGeometry.h
typedef NS_OPTIONS(NSUInteger, UIRectEdge) {
UIRectEdgeNone = 0,
UIRectEdgeTop = 1 << 0,
UIRectEdgeLeft = 1 << 1,
UIRectEdgeBottom = 1 << 2,
UIRectEdgeRight = 1 << 3,
UIRectEdgeAll = UIRectEdgeTop | UIRectEdgeLeft | UIRectEdgeBottom |
UIRectEdgeRight
};
- (void)viewDidLoad
{
[super viewDidLoad];
! // Do any additional setup after loading the view, typically from a nib.
self.extendedLayoutIncludesOpaqueBars =YES;
self.edgesForExtendedLayout = UIRectEdgeTop | UIRectEdgeBottom;
}
scroll view inset
scroll view, table view, web view
automaticallyAdjustsScrollViewInsets
UIViewController.h
@property(nonatomic,assign) BOOL automaticallyAdjustsScrollViewInsets;
UIScrollView.h
@property(nonatomic) UIEdgeInsets contentInset;
UIGeometry.h
typedef struct UIEdgeInsets {
CGFloat top, left, bottom, right;
} UIEdgeInsets;
inset {64, 0, 0, 0}
content start from 64
automaticallyAdjustsScrollViewInsets NO
full screen
• iOS 6 : (0, 0)
• iOS 7:
• only status bar : (0, 20)
• status bar + nav bar: (0, 64)
topLayoutGuide &
bottomLayoutGuide
topLayoutGuide
nav bar
topLayoutGuide &
bottomLayoutGuide
topLayoutGuide status bar
topLayoutGuide &
bottomLayoutGuide
- (void)viewDidLoad
{
[super viewDidLoad];
UIView *blueView = [[UIView alloc] initWithFrame:CGRectZero];
blueView.backgroundColor = [UIColor blueColor];
[self.view addSubview:blueView];
blueView.translatesAutoresizingMaskIntoConstraints = NO;
id topLayoutGuide = self.topLayoutGuide;
NSDictionary *viewsDictionary =
NSDictionaryOfVariableBindings(blueView,
topLayoutGuide);
[self.view addConstraints:[NSLayoutConstraint
constraintsWithVisualFormat:@"V:
[topLayoutGuide]-10-[blueView(100)]" options:0 metrics:nil
views:viewsDictionary]];
[self.view addConstraints:[NSLayoutConstraint
constraintsWithVisualFormat:@"H:|-50-[blueView(100)]" options:0
metrics:nil
views:viewsDictionary]];
}
bar
UIBarPositionAny
UIBarPositionBottom
UIBarPositionTop
UIBarPositionTopAttached
- (void)viewDidLoad
{
[super viewDidLoad];
!
UIImage *image = [UIImage imageNamed:@"bar.png"];
UINavigationBar *navBar = [[UINavigationBar alloc]
initWithFrame:CGRectMake(0, 20, 320, 44)];
[navBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
[self.view addSubview:navBar];
navBar.delegate = self;
}
- (UIBarPosition)positionForBar:(id <UIBarPositioning>)bar
{
return UIBarPositionTopAttached;
}
status bar
: status bar
:
- (UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleLightContent;
}
- (UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleDefault;
}
( )
method controller status bar
controller default
status bar
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:
(NSDictionary *)launchOptions
{
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
return YES;
}
status bar controller
View controller-based status bar appearance
(UIViewControllerBasedStatusBarAppearance)
NO setStatusBarStyle:
hide status bar
view controller
[[UIApplication sharedApplication]
setStatusBarHidden:isHide
withAnimation:UIStatusBarAnimationFade];
!
hide status bar
- (BOOL)prefersStatusBarHidden
{
return YES;
}
controller status bar
controller
[[UIApplication sharedApplication] setStatusBarHidden:YES
withAnimation:UIStatusBarAnimationFade];
work !
status bar
nav bar
• scroll
• 44 64
• nav bar 64
point
bar button item
UIImage *image = [UIImage imageNamed:@"foodIcon.png"];
image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithImage:image
style:UIBarButtonItemStylePlain target:self action:@selector(showSetting:)];
self.navigationItem.rightBarButtonItem = barButtonItem;
iOS 7 iOS 6 initWithCustomView
image render mode
UIImage.h
typedef NS_ENUM(NSInteger, UIImageRenderingMode) {
UIImageRenderingModeAutomatic,
UIImageRenderingModeAlwaysOriginal,
UIImageRenderingModeAlwaysTemplate,
}
UIImageRenderingModeAlwaysTemplate:
tint color
UINavigationController
scroll
• scroll
•
• ex:
• :
UINavigationController.h
@property(nonatomic, readonly) UIGestureRecognizer
*interactivePopGestureRecognizer;
self.navigationController.interactivePopGestureRecognizer.enabled
= NO;
delete
tab bar image
UITabBarItem.h
@property(nonatomic,retain) UIImage *selectedImage;
tint color
tab
keyboard
default
UITextInputTraits.h
UIKeyboardAppearanceDefault
UIKeyboardAppearanceDark
UIKeyboardAppearanceLight
textField.keyboardAppearance = UIKeyboardAppearanceDark;
keyboard
UIScrollView.h
typedef NS_ENUM(NSInteger, UIScrollViewKeyboardDismissMode) {
UIScrollViewKeyboardDismissModeNone,
UIScrollViewKeyboardDismissModeOnDrag,
UIScrollViewKeyboardDismissModeInteractive,
}
scrollView.keyboardDismissMode =
UIScrollViewKeyboardDismissModeInteractive;
UIScrollViewKeyboardDismissModeOnDrag:
scroll (ex: )
UIScrollViewKeyboardDismissModeInteractive:
scroll (ex: )
Picker
self.picker.backgroundColor =
[UIColor whiteColor];
:
picker
UITextField *textField = [[UITextField alloc]
initWithFrame:CGRectMake(10, 50, 100, 30)];
textField.borderStyle = UITextBorderStyleRoundedRect;
[self.view addSubview:textField];
UIDatePicker *picker = [[UIDatePicker alloc] initWithFrame:
CGRectMake(0, 0, 320, 200)];
textField.inputView = picker;
alert view
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Hello" message:nil
delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles: nil];
[alertView show];
UIView *blueView = [[UIView alloc] initWithFrame:CGRectMake(10, 10, 50, 50)];
blueView.backgroundColor = [UIColor blueColor];
[alertView addSubview:blueView];
addSubview !
UIAlertView.h
typedef NS_ENUM(NSInteger, UIAlertViewStyle) {
UIAlertViewStyleDefault = 0,
UIAlertViewStyleSecureTextInput,
UIAlertViewStylePlainTextInput,
UIAlertViewStyleLoginAndPasswordInput
};
Text Size
Text Styles
1
2
3
UIFontDescriptor.h
UIFontTextStyleHeadline
UIFontTextStyleSubheadline
UIFontTextStyleBody
UIFontTextStyleFootnote
UIFontTextStyleCaption1
UIFontTextStyleCaption2
self.nameLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline];
no change ?
App
-(void)updateTextSize
{
self.nameLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline];
}
- (void)viewDidLoad
{
[super viewDidLoad];
! // Do any additional setup after loading the view, typically from a nib.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(updateTextSize)
name:UIContentSizeCategoryDidChangeNotification object:nil];
}
:
-(void)updateTextSize
{
UIFontDescriptor *userFont = [UIFontDescriptor
preferredFontDescriptorWithTextStyle:UIFontTextStyleHeadline];
float userFontSize = [userFont pointSize];
self.nameLabel.font = [UIFont fontWithName:@"Chalkduster" size:userFontSize];
}
- (void)viewDidLoad
{
[super viewDidLoad];
UIFontDescriptor *userFont = [UIFontDescriptor
preferredFontDescriptorWithTextStyle:UIFontTextStyleHeadline];
float userFontSize = [userFont pointSize];
self.nameLabel.font = [UIFont fontWithName:@"Chalkduster" size:userFontSize];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(updateTextSize)
name:UIContentSizeCategoryDidChangeNotification object:nil];
}
preferredFontDescriptorWithTextStyle:
layout
• :
auto layout
ex: label size size
• :
size
ex:
UIFont *nameLabelFont = [UIFont
preferredFontForTextStyle:UIFontTextStyleHeadline];
CGSize nameLabelFontSize = [@"Peter Pan" sizeWithAttributes:
@{NSFontAttributeName: nameLabelFont}];
Motion Effects
Parallax effect
3D
UIInterpolatingMotionEffect
- (void)viewDidLoad
{
[super viewDidLoad];
!
UIInterpolatingMotionEffect *horizontalMotionEffect =
[[UIInterpolatingMotionEffect alloc]
initWithKeyPath:@"center.x"
type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];
horizontalMotionEffect.minimumRelativeValue = @-50;
horizontalMotionEffect.maximumRelativeValue = @50;
[self.imageView addMotionEffect:horizontalMotionEffect];
}
UIMotionEffect
demo
horizontalMotionEffect.minimumRelativeValue = @-500;
horizontalMotionEffect.maximumRelativeValue = @500;
- (void)viewDidLoad
{
[super viewDidLoad];
UIInterpolatingMotionEffect *horizontalMotionEffect = [[UIInterpolatingMotionEffect
alloc] initWithKeyPath:@"center.x"
type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];
horizontalMotionEffect.minimumRelativeValue = @-50;
horizontalMotionEffect.maximumRelativeValue = @50;
[self.imageView addMotionEffect:horizontalMotionEffect];
UIInterpolatingMotionEffect *verticalMotionEffect = [[UIInterpolatingMotionEffect
alloc] initWithKeyPath:@"center.y"
type:UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis];
verticalMotionEffect.minimumRelativeValue = @-50;
verticalMotionEffect.maximumRelativeValue = @50;
[self.imageView addMotionEffect:verticalMotionEffect];
}
UIMotionEffectGroup *group = [[UIMotionEffectGroup alloc] init];
group.motionEffects = @[horizontalMotionEffect,
verticalMotionEffect];
[self.imageView addMotionEffect:group];
modify CALayer
- (void)viewDidLoad
{
[super viewDidLoad];
self.imageView.layer.borderColor = [UIColor yellowColor].CGColor;
self.imageView.layer.borderWidth = 20;
UIInterpolatingMotionEffect *horizontalMotionEffect =
[[UIInterpolatingMotionEffect alloc]
initWithKeyPath:@"layer.borderWidth"
type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];
horizontalMotionEffect.minimumRelativeValue = @-20;
horizontalMotionEffect.maximumRelativeValue = @20;
[self.imageView addMotionEffect:horizontalMotionEffect];
}
motion effect
• UIMotionEffect
• keyPathsAndRelativeValuesForViewerOffset:
http://www.teehanlax.com/blog/introduction-to-uimotioneffect/
3D
UIKit Dynamics
iOS 7
• Core Animation:
• but
...
•
• UIAnimator:
physical engine
• UIDynamicBehavior:
UIAnimator
• UIDynamicItem protocol:
UIDynamicItem protocol
UIDynamicBehavior
• ReferenceView:
UIAnimator
2D
• Gravity
• Collision
• Attachments
• Snap
• Forces
• Item properties
UIDynamicItem
@interface UIView : UIResponder<NSCoding,
UIAppearance, UIAppearanceContainer,
UIDynamicItem> {
Architecture
Apple Sample Code
UIKit Dynamics Catalog
https://developer.apple.com/library/ios/samplecode/DynamicsCatalog
APLGravityViewController
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
UIDynamicAnimator *animator = [[UIDynamicAnimator
alloc] initWithReferenceView:self.view];
UIGravityBehavior *gravityBeahvior =
[[UIGravityBehavior alloc]
initWithItems:@[self.square1]];
[animator addBehavior:gravityBeahvior];
self.animator = animator;
}
@interface APLGravityViewController ()
@property (nonatomic, weak) IBOutlet UIImageView *square1;
@property (nonatomic, strong) UIDynamicAnimator *animator;
@end
• UIDynamicAnimator
• UIGravityBehavior
UIGravityBehavior
• UIGravityBehavior
UIDynamicAnimator !
UIGravityBehavior
gravityBeahvior.gravityDirection = CGVectorMake(1, -1);
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
UIDynamicAnimator *animator = [[UIDynamicAnimator alloc]
initWithReferenceView:self.view];
UIGravityBehavior *gravityBeahvior = [[UIGravityBehavior alloc]
initWithItems:@[self.square1]];
[animator addBehavior:gravityBeahvior];
UICollisionBehavior *collisionBehavior = [[UICollisionBehavior alloc]
initWithItems:@[self.square1]];
collisionBehavior.translatesReferenceBoundsIntoBoundary = YES;
collisionBehavior.collisionDelegate = self;
[animator addBehavior:collisionBehavior];
self.animator = animator;
}
APLCollisionGravityViewController
- (void)collisionBehavior:(UICollisionBehavior*)behavior
beganContactForItem:(id<UIDynamicItem>)item
withBoundaryIdentifier:(id<NSCopying>)identifier atPoint:
(CGPoint)p
{
[(UIView*)item setTintColor:[UIColor lightGrayColor]];
}
- (void)collisionBehavior:(UICollisionBehavior*)behavior
endedContactForItem:(id<UIDynamicItem>)item
withBoundaryIdentifier:(id<NSCopying>)identifier
{
[(UIView*)item setTintColor:[UIColor darkGrayColor]];
}
UIView *square2 = [[UIView alloc] initWithFrame:
CGRectMake(160, 300, 100, 100)];
square2.backgroundColor = [UIColor blueColor];
[self.view addSubview:square2];
UIKit Dynamics
UICollisionBehavior *collisionBehavior = [[UICollisionBehavior
alloc] initWithItems:@[self.square1, square2]];
Item Property
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
UIDynamicAnimator *animator = [[UIDynamicAnimator alloc]
initWithReferenceView:self.view];
UIGravityBehavior *gravityBeahvior = [[UIGravityBehavior alloc]
initWithItems:@[self.square1, self.square2]];
UICollisionBehavior *collisionBehavior = [[UICollisionBehavior alloc]
initWithItems:@[self.square1, self.square2]];
collisionBehavior.translatesReferenceBoundsIntoBoundary = YES;
self.square2PropertiesBehavior = [[UIDynamicItemBehavior alloc]
initWithItems:@[self.square2]];
self.square2PropertiesBehavior.elasticity = 0.5;
self.square1PropertiesBehavior = [[UIDynamicItemBehavior alloc]
initWithItems:@[self.square1]];
[animator addBehavior:self.square1PropertiesBehavior];
[animator addBehavior:self.square2PropertiesBehavior];
[animator addBehavior:gravityBeahvior];
[animator addBehavior:collisionBehavior];
self.animator = animator;
}
APLItemPropertiesViewController
item property
• elasticity: 0 ~ 1
• friction: 0 ~ 1
• density: 1
• resistance: 0
• angularResistance:
• allowsRotation: rotate
Replay
- (IBAction)replayAction:(id)sender
{
// Moving an item does not reset its velocity. Here we do that manually
// using the dynamic item behaviors, adding the inverse velocity for each
// square.
[self.square1PropertiesBehavior addLinearVelocity:CGPointMake(0, -1 *
[self.square1PropertiesBehavior linearVelocityForItem:self.square1].y)
forItem:self.square1];
self.square1.center = CGPointMake(90, 171);
[self.animator updateItemUsingCurrentState:self.square1];
[self.square2PropertiesBehavior addLinearVelocity:CGPointMake(0, -1 *
[self.square2PropertiesBehavior linearVelocityForItem:self.square2].y)
forItem:self.square2];
self.square2.center = CGPointMake(230, 171);
[self.animator updateItemUsingCurrentState:self.square2];
}
Combining behaviors
addChildBehavior
- (instancetype)initWithWeight:(id<UIDynamicItem>)item suspendedFromPoint:(CGPoint)p
{
self = [super init];
if (self)
{
UIGravityBehavior *gravityBehavior = [[UIGravityBehavior alloc]
initWithItems:@[item]];
UIAttachmentBehavior *attachmentBehavior = [[UIAttachmentBehavior alloc]
initWithItem:item attachedToAnchor:p];
UIAttachmentBehavior *draggingBehavior = [[UIAttachmentBehavior alloc]
initWithItem:item attachedToAnchor:CGPointZero];
UIPushBehavior *pushBehavior = [[UIPushBehavior alloc] initWithItems:@[item]
mode:UIPushBehaviorModeInstantaneous];
pushBehavior.active = NO;
[self addChildBehavior:gravityBehavior];
[self addChildBehavior:attachmentBehavior];
[self addChildBehavior:pushBehavior];
self.draggingBehavior = draggingBehavior;
self.pushBehavior = pushBehavior;
}
return self;
}
APLPendulumBehavior
https://github.com/shu223/iOS7-Sampler

More Related Content

What's hot

Academy PRO: React native - navigation
Academy PRO: React native - navigationAcademy PRO: React native - navigation
Academy PRO: React native - navigationBinary Studio
 
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점Jeado Ko
 
Bootstrap과 UI-Bootstrap
Bootstrap과 UI-BootstrapBootstrap과 UI-Bootstrap
Bootstrap과 UI-BootstrapWebFrameworks
 
Intro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran MizrahiIntro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran MizrahiRan Mizrahi
 
iPhone dev intro
iPhone dev introiPhone dev intro
iPhone dev introVonbo
 
Desenvolvimento iOS - Aula 4
Desenvolvimento iOS - Aula 4Desenvolvimento iOS - Aula 4
Desenvolvimento iOS - Aula 4Saulo Arruda
 
An in-depth look at jQuery UI
An in-depth look at jQuery UIAn in-depth look at jQuery UI
An in-depth look at jQuery UIPaul Bakaus
 
How dojo works
How dojo worksHow dojo works
How dojo worksAmit Tyagi
 
Ember.js Tokyo event 2014/09/22 (English)
Ember.js Tokyo event 2014/09/22 (English)Ember.js Tokyo event 2014/09/22 (English)
Ember.js Tokyo event 2014/09/22 (English)Yuki Shimada
 
ScalikeJDBC Tutorial for Beginners
ScalikeJDBC Tutorial for BeginnersScalikeJDBC Tutorial for Beginners
ScalikeJDBC Tutorial for BeginnersKazuhiro Sera
 
Connect.Tech- Level Up Your Game With TravisCI
Connect.Tech- Level Up Your Game With TravisCIConnect.Tech- Level Up Your Game With TravisCI
Connect.Tech- Level Up Your Game With TravisCIstable|kernel
 
Client-side MVC with Backbone.js (reloaded)
Client-side MVC with Backbone.js (reloaded)Client-side MVC with Backbone.js (reloaded)
Client-side MVC with Backbone.js (reloaded)iloveigloo
 
Introduction to node.js by Ran Mizrahi @ Reversim Summit
Introduction to node.js by Ran Mizrahi @ Reversim SummitIntroduction to node.js by Ran Mizrahi @ Reversim Summit
Introduction to node.js by Ran Mizrahi @ Reversim SummitRan Mizrahi
 
IndexedDB - Querying and Performance
IndexedDB - Querying and PerformanceIndexedDB - Querying and Performance
IndexedDB - Querying and PerformanceParashuram N
 
Dependency Injection @ AngularJS
Dependency Injection @ AngularJSDependency Injection @ AngularJS
Dependency Injection @ AngularJSRan Mizrahi
 
Building scalable applications with angular js
Building scalable applications with angular jsBuilding scalable applications with angular js
Building scalable applications with angular jsAndrew Alpert
 

What's hot (19)

Academy PRO: React native - navigation
Academy PRO: React native - navigationAcademy PRO: React native - navigation
Academy PRO: React native - navigation
 
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
 
Bootstrap과 UI-Bootstrap
Bootstrap과 UI-BootstrapBootstrap과 UI-Bootstrap
Bootstrap과 UI-Bootstrap
 
Intro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran MizrahiIntro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran Mizrahi
 
Django Heresies
Django HeresiesDjango Heresies
Django Heresies
 
iPhone dev intro
iPhone dev introiPhone dev intro
iPhone dev intro
 
Desenvolvimento iOS - Aula 4
Desenvolvimento iOS - Aula 4Desenvolvimento iOS - Aula 4
Desenvolvimento iOS - Aula 4
 
An in-depth look at jQuery UI
An in-depth look at jQuery UIAn in-depth look at jQuery UI
An in-depth look at jQuery UI
 
How dojo works
How dojo worksHow dojo works
How dojo works
 
Ember.js Tokyo event 2014/09/22 (English)
Ember.js Tokyo event 2014/09/22 (English)Ember.js Tokyo event 2014/09/22 (English)
Ember.js Tokyo event 2014/09/22 (English)
 
ScalikeJDBC Tutorial for Beginners
ScalikeJDBC Tutorial for BeginnersScalikeJDBC Tutorial for Beginners
ScalikeJDBC Tutorial for Beginners
 
Connect.Tech- Level Up Your Game With TravisCI
Connect.Tech- Level Up Your Game With TravisCIConnect.Tech- Level Up Your Game With TravisCI
Connect.Tech- Level Up Your Game With TravisCI
 
Extending Studio
Extending StudioExtending Studio
Extending Studio
 
Django at Scale
Django at ScaleDjango at Scale
Django at Scale
 
Client-side MVC with Backbone.js (reloaded)
Client-side MVC with Backbone.js (reloaded)Client-side MVC with Backbone.js (reloaded)
Client-side MVC with Backbone.js (reloaded)
 
Introduction to node.js by Ran Mizrahi @ Reversim Summit
Introduction to node.js by Ran Mizrahi @ Reversim SummitIntroduction to node.js by Ran Mizrahi @ Reversim Summit
Introduction to node.js by Ran Mizrahi @ Reversim Summit
 
IndexedDB - Querying and Performance
IndexedDB - Querying and PerformanceIndexedDB - Querying and Performance
IndexedDB - Querying and Performance
 
Dependency Injection @ AngularJS
Dependency Injection @ AngularJSDependency Injection @ AngularJS
Dependency Injection @ AngularJS
 
Building scalable applications with angular js
Building scalable applications with angular jsBuilding scalable applications with angular js
Building scalable applications with angular js
 

Viewers also liked

利用 iOS App 技術創業的 13 個方法
利用 iOS App 技術創業的 13 個方法利用 iOS App 技術創業的 13 個方法
利用 iOS App 技術創業的 13 個方法彼得潘 Pan
 
第一次程式親密接觸
第一次程式親密接觸第一次程式親密接觸
第一次程式親密接觸彼得潘 Pan
 
Standford 2015 week8
Standford 2015 week8Standford 2015 week8
Standford 2015 week8彼得潘 Pan
 
Standford 2015 week9
Standford 2015 week9Standford 2015 week9
Standford 2015 week9彼得潘 Pan
 
打造你的第一個iPhone APP
打造你的第一個iPhone APP打造你的第一個iPhone APP
打造你的第一個iPhone APP彼得潘 Pan
 
如何變成iOS App開發魔法師
如何變成iOS App開發魔法師如何變成iOS App開發魔法師
如何變成iOS App開發魔法師彼得潘 Pan
 
不能承受的感動 - iOS App實機測試
不能承受的感動 - iOS App實機測試不能承受的感動 - iOS App實機測試
不能承受的感動 - iOS App實機測試彼得潘 Pan
 
Standford 2015 week7: 1. Unwind Segues, Alerts, Timers, View Animation 2. Dyn...
Standford 2015 week7: 1. Unwind Segues, Alerts, Timers, View Animation 2. Dyn...Standford 2015 week7: 1. Unwind Segues, Alerts, Timers, View Animation 2. Dyn...
Standford 2015 week7: 1. Unwind Segues, Alerts, Timers, View Animation 2. Dyn...彼得潘 Pan
 
iOS 入門教學
iOS 入門教學iOS 入門教學
iOS 入門教學Steven Shen
 

Viewers also liked (10)

利用 iOS App 技術創業的 13 個方法
利用 iOS App 技術創業的 13 個方法利用 iOS App 技術創業的 13 個方法
利用 iOS App 技術創業的 13 個方法
 
第一次程式親密接觸
第一次程式親密接觸第一次程式親密接觸
第一次程式親密接觸
 
Standford 2015 week8
Standford 2015 week8Standford 2015 week8
Standford 2015 week8
 
Standford 2015 week9
Standford 2015 week9Standford 2015 week9
Standford 2015 week9
 
打造你的第一個iPhone APP
打造你的第一個iPhone APP打造你的第一個iPhone APP
打造你的第一個iPhone APP
 
如何變成iOS App開發魔法師
如何變成iOS App開發魔法師如何變成iOS App開發魔法師
如何變成iOS App開發魔法師
 
不能承受的感動 - iOS App實機測試
不能承受的感動 - iOS App實機測試不能承受的感動 - iOS App實機測試
不能承受的感動 - iOS App實機測試
 
Standford 2015 week7: 1. Unwind Segues, Alerts, Timers, View Animation 2. Dyn...
Standford 2015 week7: 1. Unwind Segues, Alerts, Timers, View Animation 2. Dyn...Standford 2015 week7: 1. Unwind Segues, Alerts, Timers, View Animation 2. Dyn...
Standford 2015 week7: 1. Unwind Segues, Alerts, Timers, View Animation 2. Dyn...
 
為愛打造App
為愛打造App為愛打造App
為愛打造App
 
iOS 入門教學
iOS 入門教學iOS 入門教學
iOS 入門教學
 

Similar to iOS 7 SDK特訓班

Programming iOS in C#
Programming iOS in C#Programming iOS in C#
Programming iOS in C#Frank Krueger
 
I phone勉強会 (2011.11.23)
I phone勉強会 (2011.11.23)I phone勉強会 (2011.11.23)
I phone勉強会 (2011.11.23)Katsumi Kishikawa
 
MOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app developmentMOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app developmentanistar sung
 
Conceitos e prática no desenvolvimento iOS - Mobile Conf 2014
Conceitos e prática no desenvolvimento iOS - Mobile Conf 2014Conceitos e prática no desenvolvimento iOS - Mobile Conf 2014
Conceitos e prática no desenvolvimento iOS - Mobile Conf 2014Fábio Pimentel
 
Leaving Interface Builder Behind
Leaving Interface Builder BehindLeaving Interface Builder Behind
Leaving Interface Builder BehindJohn Wilker
 
iPhone/iPad开发讲座 第五讲 定制视图和多点触摸
iPhone/iPad开发讲座 第五讲 定制视图和多点触摸iPhone/iPad开发讲座 第五讲 定制视图和多点触摸
iPhone/iPad开发讲座 第五讲 定制视图和多点触摸Hao Peiqiang
 
Style vs. Content and Clean Theming in iOS
Style vs. Content and Clean Theming in iOSStyle vs. Content and Clean Theming in iOS
Style vs. Content and Clean Theming in iOSKeith Norman
 
Developing iOS REST Applications
Developing iOS REST ApplicationsDeveloping iOS REST Applications
Developing iOS REST Applicationslmrei
 
Mobile App Development: Primi passi con NativeScript e Angular 2
Mobile App Development: Primi passi con NativeScript e Angular 2Mobile App Development: Primi passi con NativeScript e Angular 2
Mobile App Development: Primi passi con NativeScript e Angular 2Filippo Matteo Riggio
 
iOS 2 - The practical Stuff
iOS 2 - The practical StuffiOS 2 - The practical Stuff
iOS 2 - The practical StuffPetr Dvorak
 
MFF UK - Advanced iOS Topics
MFF UK - Advanced iOS TopicsMFF UK - Advanced iOS Topics
MFF UK - Advanced iOS TopicsPetr Dvorak
 
漫游iOS开发指南
漫游iOS开发指南漫游iOS开发指南
漫游iOS开发指南jeff kit
 
Webエンジニアから見たiOS5
Webエンジニアから見たiOS5Webエンジニアから見たiOS5
Webエンジニアから見たiOS5Satoshi Asano
 
iOS Einführung am Beispiel von play NEXT TEE
iOS Einführung am Beispiel von play NEXT TEEiOS Einführung am Beispiel von play NEXT TEE
iOS Einführung am Beispiel von play NEXT TEEHendrik Ebel
 
Heroku pop-behind-the-sense
Heroku pop-behind-the-senseHeroku pop-behind-the-sense
Heroku pop-behind-the-senseBen Lin
 
Cocoa Heads Tricity - Design Patterns
Cocoa Heads Tricity - Design PatternsCocoa Heads Tricity - Design Patterns
Cocoa Heads Tricity - Design PatternsMaciej Burda
 
Hızlı Cocoa Geliştirme (Develop your next cocoa app faster!)
Hızlı Cocoa Geliştirme (Develop your next cocoa app faster!)Hızlı Cocoa Geliştirme (Develop your next cocoa app faster!)
Hızlı Cocoa Geliştirme (Develop your next cocoa app faster!)Sarp Erdag
 
iPhone Development Intro
iPhone Development IntroiPhone Development Intro
iPhone Development IntroLuis Azevedo
 

Similar to iOS 7 SDK特訓班 (20)

Programming iOS in C#
Programming iOS in C#Programming iOS in C#
Programming iOS in C#
 
UIWebView Tips
UIWebView TipsUIWebView Tips
UIWebView Tips
 
I phone勉強会 (2011.11.23)
I phone勉強会 (2011.11.23)I phone勉強会 (2011.11.23)
I phone勉強会 (2011.11.23)
 
MOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app developmentMOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app development
 
Conceitos e prática no desenvolvimento iOS - Mobile Conf 2014
Conceitos e prática no desenvolvimento iOS - Mobile Conf 2014Conceitos e prática no desenvolvimento iOS - Mobile Conf 2014
Conceitos e prática no desenvolvimento iOS - Mobile Conf 2014
 
Leaving Interface Builder Behind
Leaving Interface Builder BehindLeaving Interface Builder Behind
Leaving Interface Builder Behind
 
iPhone/iPad开发讲座 第五讲 定制视图和多点触摸
iPhone/iPad开发讲座 第五讲 定制视图和多点触摸iPhone/iPad开发讲座 第五讲 定制视图和多点触摸
iPhone/iPad开发讲座 第五讲 定制视图和多点触摸
 
Style vs. Content and Clean Theming in iOS
Style vs. Content and Clean Theming in iOSStyle vs. Content and Clean Theming in iOS
Style vs. Content and Clean Theming in iOS
 
Developing iOS REST Applications
Developing iOS REST ApplicationsDeveloping iOS REST Applications
Developing iOS REST Applications
 
iOS
iOSiOS
iOS
 
Mobile App Development: Primi passi con NativeScript e Angular 2
Mobile App Development: Primi passi con NativeScript e Angular 2Mobile App Development: Primi passi con NativeScript e Angular 2
Mobile App Development: Primi passi con NativeScript e Angular 2
 
iOS 2 - The practical Stuff
iOS 2 - The practical StuffiOS 2 - The practical Stuff
iOS 2 - The practical Stuff
 
MFF UK - Advanced iOS Topics
MFF UK - Advanced iOS TopicsMFF UK - Advanced iOS Topics
MFF UK - Advanced iOS Topics
 
漫游iOS开发指南
漫游iOS开发指南漫游iOS开发指南
漫游iOS开发指南
 
Webエンジニアから見たiOS5
Webエンジニアから見たiOS5Webエンジニアから見たiOS5
Webエンジニアから見たiOS5
 
iOS Einführung am Beispiel von play NEXT TEE
iOS Einführung am Beispiel von play NEXT TEEiOS Einführung am Beispiel von play NEXT TEE
iOS Einführung am Beispiel von play NEXT TEE
 
Heroku pop-behind-the-sense
Heroku pop-behind-the-senseHeroku pop-behind-the-sense
Heroku pop-behind-the-sense
 
Cocoa Heads Tricity - Design Patterns
Cocoa Heads Tricity - Design PatternsCocoa Heads Tricity - Design Patterns
Cocoa Heads Tricity - Design Patterns
 
Hızlı Cocoa Geliştirme (Develop your next cocoa app faster!)
Hızlı Cocoa Geliştirme (Develop your next cocoa app faster!)Hızlı Cocoa Geliştirme (Develop your next cocoa app faster!)
Hızlı Cocoa Geliştirme (Develop your next cocoa app faster!)
 
iPhone Development Intro
iPhone Development IntroiPhone Development Intro
iPhone Development Intro
 

More from 彼得潘 Pan

創作 MusicKit 告白情歌
創作 MusicKit 告白情歌創作 MusicKit 告白情歌
創作 MusicKit 告白情歌彼得潘 Pan
 
如何變成 iOS App 開發魔法師 (1 小時)
如何變成 iOS App 開發魔法師 (1 小時)如何變成 iOS App 開發魔法師 (1 小時)
如何變成 iOS App 開發魔法師 (1 小時)彼得潘 Pan
 
如何變成 iOS App 開發魔法師
如何變成 iOS App 開發魔法師如何變成 iOS App 開發魔法師
如何變成 iOS App 開發魔法師彼得潘 Pan
 
Xcode 的 git 版本管理
Xcode 的 git 版本管理Xcode 的 git 版本管理
Xcode 的 git 版本管理彼得潘 Pan
 
消滅永生不死吸血鬼物件的 ARC
消滅永生不死吸血鬼物件的 ARC消滅永生不死吸血鬼物件的 ARC
消滅永生不死吸血鬼物件的 ARC彼得潘 Pan
 
你的程式開發初體驗 (以Swift為例)
你的程式開發初體驗 (以Swift為例)你的程式開發初體驗 (以Swift為例)
你的程式開發初體驗 (以Swift為例)彼得潘 Pan
 
Standford 2015 week6
Standford 2015 week6Standford 2015 week6
Standford 2015 week6彼得潘 Pan
 
Standford 2015 week5: 1.View Controller Lifecycle, Autolayout 2. Scroll View ...
Standford 2015 week5: 1.View Controller Lifecycle, Autolayout 2. Scroll View ...Standford 2015 week5: 1.View Controller Lifecycle, Autolayout 2. Scroll View ...
Standford 2015 week5: 1.View Controller Lifecycle, Autolayout 2. Scroll View ...彼得潘 Pan
 
Standford 2015 week4: 1.Protocols and Delegation, Gestures 2. Multiple MVCs
Standford 2015 week4: 1.Protocols and Delegation, Gestures 2. Multiple MVCsStandford 2015 week4: 1.Protocols and Delegation, Gestures 2. Multiple MVCs
Standford 2015 week4: 1.Protocols and Delegation, Gestures 2. Multiple MVCs彼得潘 Pan
 
Standford 2015 week3: Objective-C Compatibility, Property List, Views
Standford 2015 week3: Objective-C Compatibility, Property List, ViewsStandford 2015 week3: Objective-C Compatibility, Property List, Views
Standford 2015 week3: Objective-C Compatibility, Property List, Views彼得潘 Pan
 
Standford 2015 iOS讀書會 week2: 1. Applying MVC 2. More Swift and Foundation Fra...
Standford 2015 iOS讀書會 week2: 1. Applying MVC 2. More Swift and Foundation Fra...Standford 2015 iOS讀書會 week2: 1. Applying MVC 2. More Swift and Foundation Fra...
Standford 2015 iOS讀書會 week2: 1. Applying MVC 2. More Swift and Foundation Fra...彼得潘 Pan
 
Standford 2015 iOS讀書會 week1: 1.Logistics , iOS 8 Overview 2. More Xcode and S...
Standford 2015 iOS讀書會 week1: 1.Logistics , iOS 8 Overview 2. More Xcode and S...Standford 2015 iOS讀書會 week1: 1.Logistics , iOS 8 Overview 2. More Xcode and S...
Standford 2015 iOS讀書會 week1: 1.Logistics , iOS 8 Overview 2. More Xcode and S...彼得潘 Pan
 
打造你的第一個 iOS App
打造你的第一個 iOS App  打造你的第一個 iOS App
打造你的第一個 iOS App 彼得潘 Pan
 

More from 彼得潘 Pan (13)

創作 MusicKit 告白情歌
創作 MusicKit 告白情歌創作 MusicKit 告白情歌
創作 MusicKit 告白情歌
 
如何變成 iOS App 開發魔法師 (1 小時)
如何變成 iOS App 開發魔法師 (1 小時)如何變成 iOS App 開發魔法師 (1 小時)
如何變成 iOS App 開發魔法師 (1 小時)
 
如何變成 iOS App 開發魔法師
如何變成 iOS App 開發魔法師如何變成 iOS App 開發魔法師
如何變成 iOS App 開發魔法師
 
Xcode 的 git 版本管理
Xcode 的 git 版本管理Xcode 的 git 版本管理
Xcode 的 git 版本管理
 
消滅永生不死吸血鬼物件的 ARC
消滅永生不死吸血鬼物件的 ARC消滅永生不死吸血鬼物件的 ARC
消滅永生不死吸血鬼物件的 ARC
 
你的程式開發初體驗 (以Swift為例)
你的程式開發初體驗 (以Swift為例)你的程式開發初體驗 (以Swift為例)
你的程式開發初體驗 (以Swift為例)
 
Standford 2015 week6
Standford 2015 week6Standford 2015 week6
Standford 2015 week6
 
Standford 2015 week5: 1.View Controller Lifecycle, Autolayout 2. Scroll View ...
Standford 2015 week5: 1.View Controller Lifecycle, Autolayout 2. Scroll View ...Standford 2015 week5: 1.View Controller Lifecycle, Autolayout 2. Scroll View ...
Standford 2015 week5: 1.View Controller Lifecycle, Autolayout 2. Scroll View ...
 
Standford 2015 week4: 1.Protocols and Delegation, Gestures 2. Multiple MVCs
Standford 2015 week4: 1.Protocols and Delegation, Gestures 2. Multiple MVCsStandford 2015 week4: 1.Protocols and Delegation, Gestures 2. Multiple MVCs
Standford 2015 week4: 1.Protocols and Delegation, Gestures 2. Multiple MVCs
 
Standford 2015 week3: Objective-C Compatibility, Property List, Views
Standford 2015 week3: Objective-C Compatibility, Property List, ViewsStandford 2015 week3: Objective-C Compatibility, Property List, Views
Standford 2015 week3: Objective-C Compatibility, Property List, Views
 
Standford 2015 iOS讀書會 week2: 1. Applying MVC 2. More Swift and Foundation Fra...
Standford 2015 iOS讀書會 week2: 1. Applying MVC 2. More Swift and Foundation Fra...Standford 2015 iOS讀書會 week2: 1. Applying MVC 2. More Swift and Foundation Fra...
Standford 2015 iOS讀書會 week2: 1. Applying MVC 2. More Swift and Foundation Fra...
 
Standford 2015 iOS讀書會 week1: 1.Logistics , iOS 8 Overview 2. More Xcode and S...
Standford 2015 iOS讀書會 week1: 1.Logistics , iOS 8 Overview 2. More Xcode and S...Standford 2015 iOS讀書會 week1: 1.Logistics , iOS 8 Overview 2. More Xcode and S...
Standford 2015 iOS讀書會 week1: 1.Logistics , iOS 8 Overview 2. More Xcode and S...
 
打造你的第一個 iOS App
打造你的第一個 iOS App  打造你的第一個 iOS App
打造你的第一個 iOS App
 

Recently uploaded

A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFMichael Gough
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Jeffrey Haguewood
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsYoss Cohen
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 

Recently uploaded (20)

A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDF
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platforms
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 

iOS 7 SDK特訓班

  • 1. iOS 7 SDK 彼得潘 • • • :App - iPhone . iPad • 2012 Top 6 App
  • 3. agenda • iOS 7 SDK • Xcode 5 • Objective-C Foundation framework • iOS 6 App iOS 7 (UI ) • • 1: Motion Effects (3D) • 2: UIKit Dynamics (2D) iOS 7 SDK
  • 4. • UI • • • • device • • • • • device • App • JavaScript • iBeacon • Machine Readable Code Detection • Apple Map • Safari Reading list • UI • UI • Button • nav bar search bar • blurred background ( ) • image rendering mode (App iOS 7 ) • tint color (App iOS 7 ) • full screen status bar & navigation bar (App iOS 7 )
  • 5. UI button nav bar search bar UISearchBar *searchBar = [[UISearchBar alloc] init]; searchController = [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self]; searchController.searchResultsDataSource = self; searchController.searchResultsDelegate = self; searchController.delegate = self; searchController.displaysSearchBarInNavigationBar = YES; searchController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Close" style:UIBarButtonItemStylePlain target:self action:@selector(close:)]; UISearchDisplayController.h @property (nonatomic, assign) BOOL displaysSearchBarInNavigationBar; UINavigationController UINavigationBar
  • 6. blurred background ( ) https://developer.apple.com/downloads/index.action UIImage+ImageEffects - (UIImage *)applyBlurWithRadius:(CGFloat)blurRadius tintColor:(UIColor *)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor maskImage:(UIImage *)maskImage; UIToolbar - (void)viewDidLoad { [super viewDidLoad]; ! UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 20, 320, 320)]; [self.view addSubview:scrollView]; scrollView.contentSize = CGSizeMake(320, 1000); UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 1000)]; imageView.image = [UIImage imageNamed:@"cute.jpg"]; [scrollView addSubview:imageView]; UIToolbar *toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 20, 320, 44)]; [self.view addSubview:toolBar]; }
  • 7. UIToolbar UIToolbar *toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 20, 320, 44)]; [self.view addSubview:toolBar]; toolBar.barTintColor = [UIColor blueColor]; • view controller • CollectionView • interactive transition • Motion Effects ( ) • UIKit Dynamics ( )
  • 9. interactive transition • controller • ex: scroll UIViewControllerInteractiveTransitioning Multitasking Enhancements • (Background Fetch) • ( Remote Notification ) silent push ( )
  • 11. Text Kit Letterpress ( ) Letterpress Letterpress
  • 12. letterpress UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 320)]; label.font = [UIFont systemFontOfSize:150]; label.textAlignment = NSTextAlignmentCenter; NSDictionary *attrDic = @{NSForegroundColorAttributeName : [UIColor colorWithRed:0 green:0 blue:1 alpha:0.5], NSTextEffectAttributeName : NSTextEffectLetterpressStyle}; NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:@" " attributes:attrDic]; label.attributedText = attrString; [self.view addSubview:label]; NSAttributedString.h UIKIT_EXTERN NSString *const NSTextEffectLetterpressStyle NS_AVAILABLE_IOS(7_0); Exclusion paths
  • 13. Exclusion paths UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(0, 40, 320, 400)]; textView.backgroundColor = [UIColor clearColor]; textView.textColor = [UIColor whiteColor]; textView.text = @" "; textView.font = [UIFont systemFontOfSize:28]; UIBezierPath *path = [UIBezierPath bezierPath]; [path moveToPoint:CGPointMake(10.0, 40.0)]; [path addLineToPoint:CGPointMake(110.0, 140.0)]; [path addLineToPoint:CGPointMake(210, 40)]; [path closePath]; textView.textContainer.exclusionPaths = @[path]; [self.view addSubview:textView]; NSTextContainer.h @property(copy, NS_NONATOMIC_IOSONLY) NSArray *exclusionPaths; Text attachments
  • 14. Text attachments UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(0, 40, 320, 400)]; textView.backgroundColor = [UIColor clearColor]; NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@" "]; NSTextAttachment *attachment = [[NSTextAttachment alloc] init]; attachment.image = [UIImage imageNamed:@"shoppingIcon.png"]; [str appendAttributedString:[NSAttributedString attributedStringWithAttachment:attachment]]; [str appendAttributedString:[[NSMutableAttributedString alloc] initWithString:@" "]]; textView.attributedText = str; [self.view addSubview:textView]; NSTextAttachment.h @interface NSAttributedString (NSAttributedStringAttachmentConveniences) // A convenience method for creating an attributed string containing attachment using NSAttachmentCharacter as the base character. + (NSAttributedString *)attributedStringWithAttachment:(NSTextAttachment *)attachment NS_AVAILABLE_IOS(7_0); @end dynamic text size
  • 15. AirDrop available on iPhone 5, iPad (4th generation), iPad mini, and iPod touch (5th generation) requires an iCloud account :Wifi Bluetooth AirDrop • UIActivityViewController • Share • NSString & NSAttributedString ( Notes.app ) • UIImage & AVAsset (Photos.app ) • NSURL • Safari.app • App
  • 16. Machine Readable Code Detection support barcode • QR code • Aztec • EAN13 • EAN8 • UPC-E • PDF417 • Code 93 • Code 39 • Code 39 mod 43 AVCaptureMetadataOutput
  • 17. SSReadingList Safari Reading list NSURL *url = [NSURL URLWithString:@"https:/ /www.facebook.com/iphone.peterpan"]; [[SSReadingList defaultReadingList] addReadingListItemWithURL:url title:@" " previewText:@" " error:nil]; • CIDetectorSmile • CIDetectorEyeBlink
  • 18. Multipeer Connectivity • device • : infrastructure Wi-Fi networks peer-to-peer Wi-Fi Bluetooth Multipeer Connectivity
  • 19. Inter-App Audio • App MIDI • App iBeacon bluetooth beacon : iPhone CLBeaconRegion
  • 22. AVSpeechSynthesis AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc] init]; AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:@" "]; [synthesizer speakUtterance:utterance]; AVSpeechSynthesizer AVSpeechSynthesizer: • M7 • 5s support • CMStepCounter • typedef void (^CMStepUpdateHandler)(NSInteger numberOfSteps, NSDate *timestamp, NSError *error);
  • 23. Sprite Kit • OpenGL ES • library Cocos 2D • 2D Game Controller : Bluetooth
  • 25. JavaScriptCore • objective-c javascript • javascript objective-c Xcode 5
  • 26. Xcode 5 • UI • • Asset Catalogs • Image Slicing • • App • Interface Builder Preview • support 64 bit iOS (iPhone 5s) • • App Capability • Debug Gauges • XCTest • Continuous Integration • Autolayout • Quick Look • Xcode • OS X Mavericks
  • 27. template Asset Catalogs & Image Slicing • • ex: @2x, ~ipad • • App Icon
  • 31. Preview /** sing a song @code ViewController controller = [ViewController alloc] init]; [controller singSong:@" 89 "]; @endcode @see http://www.apple.com for more info @param song the song to sing @return YES if song name lenght > 3 */ -(BOOL)singSong:(NSString*)song { if (song.length > 3) { return YES; } else { return NO; } }
  • 32. IB auto layout • IB constraint • constraint XCTest
  • 33. Continuous Integration • build App • simulator • OS X Mavericks Server • • • on commit • periodically Continuous Integration
  • 37. @import • @import QuartzCore; • @import QuartzCore.CoreAnimation; • #import @import ex: (1) #import <UIKit/UIKit.h> @import UIKit; (2) #import <iAd/ADBannerView.h> @import iAd.ADBannerView; • module #import enable modules
  • 39. instancetype NSArray.h + (instancetype)array; return type array NSArray.h - (id)firstObject NS_AVAILABLE(10_6, 4_0); - (id)lastObject; firstObject iOS 7 NSArray *array = [[NSArray alloc] init]; NSLog(@"array %@", array[0]); NSArray *array = [[NSArray alloc] init]; NSLog(@"array %@", [array firstObject]); nil
  • 40. iOS 6 App iOS 7 iOS 7 iOS 6
  • 41. iOS 6 App iOS 7 • App Icon • Asset Catalogs Image Slicing • tint color • iOS • full screen status bar & navigation bar • image render mode • interactivePopGestureRecognizer • keyboard , picker & alert view App Icon size App Icon (pixel) iPhone 57 * 57 iPhone Retina 114 * 114 iPad (iPad mini) 72 * 72 iPad Retina 144 * 144 iPhone Retina iOS 7 120 * 120 iPad (iPad mini) iOS 7 76 * 76 iPad Retina iOS 7 152 * 152
  • 42. iOS 7 Retina App iPhone App iOS 7 -> retina size Launch Image (pixel) iPhone 3.5 320 * 480 iPhone Retina 3.5 640 * 960 iPhone Retina 4 640 * 1136 iPad (iPad mini) 768 * 1024 1024 * 768 iPad Retina 1536 * 2048 2048 * 1536 full screen status bar
  • 43. App Icon asset catalogs Use Asset Catalog asset catalogs
  • 45. iOS AppIcon attributes inspectorps: Development Target • support png • • Asset Catalogs andy.png tony.png self.imageView.image = [UIImage imageNamed:@"handsome"];
  • 46. Asset Catalogs andy.png tony.png chilam.png tai.pnglin.png Image Slicing
  • 47. tint color tint color • UI • active UI tab • UI (ex: UIButton ) • button
  • 48. UIView tintColor property • default: blue • tintColor : 1. 2. superview tintColor superview 3. superview tintColor • App 1. UI tint color 2. App tint color UIView.h @property(nonatomic,retain) UIColor *tintColor NS_AVAILABLE_IOS(7_0); view superview tintColor App tint color • window tintColor • storyboard global tint
  • 49. tint color self.view.tintColor = [UIColor orangeColor]; iOS 6 Crash tintColor property iOS 7 iOS if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) { } else { } NSObjCRuntime.h #define NSFoundationVersionNumber_iPhoneOS_2_0!678.24 #define NSFoundationVersionNumber_iPhoneOS_2_1 678.26 #define NSFoundationVersionNumber_iPhoneOS_2_2 678.29 #define NSFoundationVersionNumber_iPhoneOS_3_0 678.47 #define NSFoundationVersionNumber_iPhoneOS_3_1 678.51 #define NSFoundationVersionNumber_iPhoneOS_3_2 678.60 #define NSFoundationVersionNumber_iOS_4_0 751.32 #define NSFoundationVersionNumber_iOS_4_1 751.37 #define NSFoundationVersionNumber_iOS_4_2 751.49 #define NSFoundationVersionNumber_iOS_4_3 751.49 #define NSFoundationVersionNumber_iOS_5_0 881.00 #define NSFoundationVersionNumber_iOS_5_1 890.10 #define NSFoundationVersionNumber_iOS_6_0 993.00 #define NSFoundationVersionNumber_iOS_6_1 993.00 iOS SDK: crash iOS deprecated SDK: do nothing
  • 50. iOS 6 tintColor UINavigationBar.h @property(nonatomic,retain) UIColor *tintColor; @property(nonatomic,retain) UIColor *barTintColor NS_AVAILABLE_IOS(7_0) UI_APPEARANCE_SELECTOR; iOS 7 barTintColor full screen status bar navigation bar cell: UITableViewStyleGrouped
  • 51. view controller’s view size • iOS 7 view size full screen • iOS 6 view size full screen • status bar black translucent • controller wantsFullScreenLayout YES • navigation bar translucent YES controller 320 * 568
  • 52. nav bar & tab bar nav bar controller controller tab bar ( 519 = 568 - 49) Extend Edges
  • 53. bar translucent nva bar translucent Under Top bars tab bar translucent Under Bottom bars Under Opaque Bars
  • 54. bar 455 = 568 - 20 - 44 -49 UIViewController.h @property(nonatomic,assign) UIRectEdge edgesForExtendedLayout; @property(nonatomic,assign) BOOL extendedLayoutIncludesOpaqueBars; UIGeometry.h typedef NS_OPTIONS(NSUInteger, UIRectEdge) { UIRectEdgeNone = 0, UIRectEdgeTop = 1 << 0, UIRectEdgeLeft = 1 << 1, UIRectEdgeBottom = 1 << 2, UIRectEdgeRight = 1 << 3, UIRectEdgeAll = UIRectEdgeTop | UIRectEdgeLeft | UIRectEdgeBottom | UIRectEdgeRight };
  • 55. - (void)viewDidLoad { [super viewDidLoad]; ! // Do any additional setup after loading the view, typically from a nib. self.extendedLayoutIncludesOpaqueBars =YES; self.edgesForExtendedLayout = UIRectEdgeTop | UIRectEdgeBottom; } scroll view inset scroll view, table view, web view
  • 56. automaticallyAdjustsScrollViewInsets UIViewController.h @property(nonatomic,assign) BOOL automaticallyAdjustsScrollViewInsets; UIScrollView.h @property(nonatomic) UIEdgeInsets contentInset; UIGeometry.h typedef struct UIEdgeInsets { CGFloat top, left, bottom, right; } UIEdgeInsets; inset {64, 0, 0, 0} content start from 64 automaticallyAdjustsScrollViewInsets NO
  • 57. full screen • iOS 6 : (0, 0) • iOS 7: • only status bar : (0, 20) • status bar + nav bar: (0, 64) topLayoutGuide & bottomLayoutGuide topLayoutGuide nav bar
  • 58. topLayoutGuide & bottomLayoutGuide topLayoutGuide status bar topLayoutGuide & bottomLayoutGuide - (void)viewDidLoad { [super viewDidLoad]; UIView *blueView = [[UIView alloc] initWithFrame:CGRectZero]; blueView.backgroundColor = [UIColor blueColor]; [self.view addSubview:blueView]; blueView.translatesAutoresizingMaskIntoConstraints = NO; id topLayoutGuide = self.topLayoutGuide; NSDictionary *viewsDictionary = NSDictionaryOfVariableBindings(blueView, topLayoutGuide); [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V: [topLayoutGuide]-10-[blueView(100)]" options:0 metrics:nil views:viewsDictionary]]; [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-50-[blueView(100)]" options:0 metrics:nil views:viewsDictionary]]; }
  • 59. bar UIBarPositionAny UIBarPositionBottom UIBarPositionTop UIBarPositionTopAttached - (void)viewDidLoad { [super viewDidLoad]; ! UIImage *image = [UIImage imageNamed:@"bar.png"]; UINavigationBar *navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 20, 320, 44)]; [navBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault]; [self.view addSubview:navBar]; navBar.delegate = self; } - (UIBarPosition)positionForBar:(id <UIBarPositioning>)bar { return UIBarPositionTopAttached; } status bar : status bar
  • 60. : - (UIStatusBarStyle)preferredStatusBarStyle { return UIStatusBarStyleLightContent; } - (UIStatusBarStyle)preferredStatusBarStyle { return UIStatusBarStyleDefault; } ( ) method controller status bar controller default status bar - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; return YES; } status bar controller View controller-based status bar appearance (UIViewControllerBasedStatusBarAppearance) NO setStatusBarStyle:
  • 61. hide status bar view controller [[UIApplication sharedApplication] setStatusBarHidden:isHide withAnimation:UIStatusBarAnimationFade]; ! hide status bar - (BOOL)prefersStatusBarHidden { return YES; } controller status bar
  • 63. bar button item UIImage *image = [UIImage imageNamed:@"foodIcon.png"]; image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStylePlain target:self action:@selector(showSetting:)]; self.navigationItem.rightBarButtonItem = barButtonItem; iOS 7 iOS 6 initWithCustomView image render mode UIImage.h typedef NS_ENUM(NSInteger, UIImageRenderingMode) { UIImageRenderingModeAutomatic, UIImageRenderingModeAlwaysOriginal, UIImageRenderingModeAlwaysTemplate, } UIImageRenderingModeAlwaysTemplate: tint color
  • 64. UINavigationController scroll • scroll • • ex: • : UINavigationController.h @property(nonatomic, readonly) UIGestureRecognizer *interactivePopGestureRecognizer; self.navigationController.interactivePopGestureRecognizer.enabled = NO; delete
  • 65. tab bar image UITabBarItem.h @property(nonatomic,retain) UIImage *selectedImage; tint color tab keyboard default UITextInputTraits.h UIKeyboardAppearanceDefault UIKeyboardAppearanceDark UIKeyboardAppearanceLight textField.keyboardAppearance = UIKeyboardAppearanceDark;
  • 66. keyboard UIScrollView.h typedef NS_ENUM(NSInteger, UIScrollViewKeyboardDismissMode) { UIScrollViewKeyboardDismissModeNone, UIScrollViewKeyboardDismissModeOnDrag, UIScrollViewKeyboardDismissModeInteractive, } scrollView.keyboardDismissMode = UIScrollViewKeyboardDismissModeInteractive; UIScrollViewKeyboardDismissModeOnDrag: scroll (ex: ) UIScrollViewKeyboardDismissModeInteractive: scroll (ex: ) Picker self.picker.backgroundColor = [UIColor whiteColor]; :
  • 67. picker UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(10, 50, 100, 30)]; textField.borderStyle = UITextBorderStyleRoundedRect; [self.view addSubview:textField]; UIDatePicker *picker = [[UIDatePicker alloc] initWithFrame: CGRectMake(0, 0, 320, 200)]; textField.inputView = picker; alert view UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Hello" message:nil delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles: nil]; [alertView show]; UIView *blueView = [[UIView alloc] initWithFrame:CGRectMake(10, 10, 50, 50)]; blueView.backgroundColor = [UIColor blueColor]; [alertView addSubview:blueView]; addSubview ! UIAlertView.h typedef NS_ENUM(NSInteger, UIAlertViewStyle) { UIAlertViewStyleDefault = 0, UIAlertViewStyleSecureTextInput, UIAlertViewStylePlainTextInput, UIAlertViewStyleLoginAndPasswordInput };
  • 71. App -(void)updateTextSize { self.nameLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline]; } - (void)viewDidLoad { [super viewDidLoad]; ! // Do any additional setup after loading the view, typically from a nib. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateTextSize) name:UIContentSizeCategoryDidChangeNotification object:nil]; } :
  • 72. -(void)updateTextSize { UIFontDescriptor *userFont = [UIFontDescriptor preferredFontDescriptorWithTextStyle:UIFontTextStyleHeadline]; float userFontSize = [userFont pointSize]; self.nameLabel.font = [UIFont fontWithName:@"Chalkduster" size:userFontSize]; } - (void)viewDidLoad { [super viewDidLoad]; UIFontDescriptor *userFont = [UIFontDescriptor preferredFontDescriptorWithTextStyle:UIFontTextStyleHeadline]; float userFontSize = [userFont pointSize]; self.nameLabel.font = [UIFont fontWithName:@"Chalkduster" size:userFontSize]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateTextSize) name:UIContentSizeCategoryDidChangeNotification object:nil]; } preferredFontDescriptorWithTextStyle: layout • : auto layout ex: label size size • : size ex: UIFont *nameLabelFont = [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline]; CGSize nameLabelFontSize = [@"Peter Pan" sizeWithAttributes: @{NSFontAttributeName: nameLabelFont}];
  • 74. UIInterpolatingMotionEffect - (void)viewDidLoad { [super viewDidLoad]; ! UIInterpolatingMotionEffect *horizontalMotionEffect = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.x" type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis]; horizontalMotionEffect.minimumRelativeValue = @-50; horizontalMotionEffect.maximumRelativeValue = @50; [self.imageView addMotionEffect:horizontalMotionEffect]; } UIMotionEffect demo
  • 75. horizontalMotionEffect.minimumRelativeValue = @-500; horizontalMotionEffect.maximumRelativeValue = @500; - (void)viewDidLoad { [super viewDidLoad]; UIInterpolatingMotionEffect *horizontalMotionEffect = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.x" type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis]; horizontalMotionEffect.minimumRelativeValue = @-50; horizontalMotionEffect.maximumRelativeValue = @50; [self.imageView addMotionEffect:horizontalMotionEffect]; UIInterpolatingMotionEffect *verticalMotionEffect = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.y" type:UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis]; verticalMotionEffect.minimumRelativeValue = @-50; verticalMotionEffect.maximumRelativeValue = @50; [self.imageView addMotionEffect:verticalMotionEffect]; }
  • 76. UIMotionEffectGroup *group = [[UIMotionEffectGroup alloc] init]; group.motionEffects = @[horizontalMotionEffect, verticalMotionEffect]; [self.imageView addMotionEffect:group]; modify CALayer - (void)viewDidLoad { [super viewDidLoad]; self.imageView.layer.borderColor = [UIColor yellowColor].CGColor; self.imageView.layer.borderWidth = 20; UIInterpolatingMotionEffect *horizontalMotionEffect = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"layer.borderWidth" type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis]; horizontalMotionEffect.minimumRelativeValue = @-20; horizontalMotionEffect.maximumRelativeValue = @20; [self.imageView addMotionEffect:horizontalMotionEffect]; }
  • 77. motion effect • UIMotionEffect • keyPathsAndRelativeValuesForViewerOffset: http://www.teehanlax.com/blog/introduction-to-uimotioneffect/
  • 79. iOS 7 • Core Animation: • but ... • • UIAnimator: physical engine • UIDynamicBehavior: UIAnimator • UIDynamicItem protocol: UIDynamicItem protocol UIDynamicBehavior • ReferenceView: UIAnimator 2D
  • 80. • Gravity • Collision • Attachments • Snap • Forces • Item properties UIDynamicItem @interface UIView : UIResponder<NSCoding, UIAppearance, UIAppearanceContainer, UIDynamicItem> {
  • 81. Architecture Apple Sample Code UIKit Dynamics Catalog https://developer.apple.com/library/ios/samplecode/DynamicsCatalog
  • 82. APLGravityViewController - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; UIDynamicAnimator *animator = [[UIDynamicAnimator alloc] initWithReferenceView:self.view]; UIGravityBehavior *gravityBeahvior = [[UIGravityBehavior alloc] initWithItems:@[self.square1]]; [animator addBehavior:gravityBeahvior]; self.animator = animator; } @interface APLGravityViewController () @property (nonatomic, weak) IBOutlet UIImageView *square1; @property (nonatomic, strong) UIDynamicAnimator *animator; @end
  • 83. • UIDynamicAnimator • UIGravityBehavior UIGravityBehavior • UIGravityBehavior UIDynamicAnimator ! UIGravityBehavior
  • 84. gravityBeahvior.gravityDirection = CGVectorMake(1, -1); - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; UIDynamicAnimator *animator = [[UIDynamicAnimator alloc] initWithReferenceView:self.view]; UIGravityBehavior *gravityBeahvior = [[UIGravityBehavior alloc] initWithItems:@[self.square1]]; [animator addBehavior:gravityBeahvior]; UICollisionBehavior *collisionBehavior = [[UICollisionBehavior alloc] initWithItems:@[self.square1]]; collisionBehavior.translatesReferenceBoundsIntoBoundary = YES; collisionBehavior.collisionDelegate = self; [animator addBehavior:collisionBehavior]; self.animator = animator; } APLCollisionGravityViewController
  • 85. - (void)collisionBehavior:(UICollisionBehavior*)behavior beganContactForItem:(id<UIDynamicItem>)item withBoundaryIdentifier:(id<NSCopying>)identifier atPoint: (CGPoint)p { [(UIView*)item setTintColor:[UIColor lightGrayColor]]; } - (void)collisionBehavior:(UICollisionBehavior*)behavior endedContactForItem:(id<UIDynamicItem>)item withBoundaryIdentifier:(id<NSCopying>)identifier { [(UIView*)item setTintColor:[UIColor darkGrayColor]]; }
  • 86. UIView *square2 = [[UIView alloc] initWithFrame: CGRectMake(160, 300, 100, 100)]; square2.backgroundColor = [UIColor blueColor]; [self.view addSubview:square2]; UIKit Dynamics UICollisionBehavior *collisionBehavior = [[UICollisionBehavior alloc] initWithItems:@[self.square1, square2]];
  • 87. Item Property - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; UIDynamicAnimator *animator = [[UIDynamicAnimator alloc] initWithReferenceView:self.view]; UIGravityBehavior *gravityBeahvior = [[UIGravityBehavior alloc] initWithItems:@[self.square1, self.square2]]; UICollisionBehavior *collisionBehavior = [[UICollisionBehavior alloc] initWithItems:@[self.square1, self.square2]]; collisionBehavior.translatesReferenceBoundsIntoBoundary = YES; self.square2PropertiesBehavior = [[UIDynamicItemBehavior alloc] initWithItems:@[self.square2]]; self.square2PropertiesBehavior.elasticity = 0.5; self.square1PropertiesBehavior = [[UIDynamicItemBehavior alloc] initWithItems:@[self.square1]]; [animator addBehavior:self.square1PropertiesBehavior]; [animator addBehavior:self.square2PropertiesBehavior]; [animator addBehavior:gravityBeahvior]; [animator addBehavior:collisionBehavior]; self.animator = animator; } APLItemPropertiesViewController item property • elasticity: 0 ~ 1 • friction: 0 ~ 1 • density: 1 • resistance: 0 • angularResistance: • allowsRotation: rotate
  • 88. Replay - (IBAction)replayAction:(id)sender { // Moving an item does not reset its velocity. Here we do that manually // using the dynamic item behaviors, adding the inverse velocity for each // square. [self.square1PropertiesBehavior addLinearVelocity:CGPointMake(0, -1 * [self.square1PropertiesBehavior linearVelocityForItem:self.square1].y) forItem:self.square1]; self.square1.center = CGPointMake(90, 171); [self.animator updateItemUsingCurrentState:self.square1]; [self.square2PropertiesBehavior addLinearVelocity:CGPointMake(0, -1 * [self.square2PropertiesBehavior linearVelocityForItem:self.square2].y) forItem:self.square2]; self.square2.center = CGPointMake(230, 171); [self.animator updateItemUsingCurrentState:self.square2]; }
  • 89. Combining behaviors addChildBehavior - (instancetype)initWithWeight:(id<UIDynamicItem>)item suspendedFromPoint:(CGPoint)p { self = [super init]; if (self) { UIGravityBehavior *gravityBehavior = [[UIGravityBehavior alloc] initWithItems:@[item]]; UIAttachmentBehavior *attachmentBehavior = [[UIAttachmentBehavior alloc] initWithItem:item attachedToAnchor:p]; UIAttachmentBehavior *draggingBehavior = [[UIAttachmentBehavior alloc] initWithItem:item attachedToAnchor:CGPointZero]; UIPushBehavior *pushBehavior = [[UIPushBehavior alloc] initWithItems:@[item] mode:UIPushBehaviorModeInstantaneous]; pushBehavior.active = NO; [self addChildBehavior:gravityBehavior]; [self addChildBehavior:attachmentBehavior]; [self addChildBehavior:pushBehavior]; self.draggingBehavior = draggingBehavior; self.pushBehavior = pushBehavior; } return self; } APLPendulumBehavior https://github.com/shu223/iOS7-Sampler