通常ベースとなるビューにサブビューを追加するには、通常addSubviewを用います。しかし、iボタンの下などに追加する必要がある場合は、inserSubviewを使います。insertSubviewの追加のパラメータには、atIndex(階層を指定),aboveSubview(当該ビューの上)、belowSubview(当該ビューの下)があるようです。
その他にビューの交換(exchangeSubviewAtIndex)などもあります。
2010年5月8日土曜日
2010年5月5日水曜日
画像のアニメーションの方法
画像のアニメーションを設定するには、「アニメーションブロック」を宣言するそうです。
[UIView beginAnimations:@"View Flip(任意 or nill)" context:nill];
[UIView setAnimationDuration:1.25(秒)];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOur];
//4パターンあり。UIViewを参照
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight
forView:self.view cash:YES];
//4パターンあり。UIViewを参照
[view2object viewWillAppear:YES];
[view1object viewWillDisappaer:YES];
[view1object.view removeFromSuperview];
[self.view insertSubview: view2.view atIndex:0];
[view1object viewDidDisapper:YES];
[view2object viewDidAppear:YES];
[UIView commitAnimation]
//本ではAppearとDisapperで指定するオブジェクト逆になっていましたが、どうなんでしょう........(逆にしても何も変わらない.......)
[UIView beginAnimations:@"View Flip(任意 or nill)" context:nill];
[UIView setAnimationDuration:1.25(秒)];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOur];
//4パターンあり。UIViewを参照
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight
forView:self.view cash:YES];
//4パターンあり。UIViewを参照
[view2object viewWillAppear:YES];
[view1object viewWillDisappaer:YES];
[view1object.view removeFromSuperview];
[self.view insertSubview: view2.view atIndex:0];
[view1object viewDidDisapper:YES];
[view2object viewDidAppear:YES];
[UIView commitAnimation]
//本ではAppearとDisapperで指定するオブジェクト逆になっていましたが、どうなんでしょう........(逆にしても何も変わらない.......)
2010年5月4日火曜日
2つのビューによる回転のサポート
2つのビューを使った回転時の表示サポートを勉強してみました。
表示にあたり、self.view.transformとあるのは(UIView)self.viewのプロパティで、オブジェクトのサイズ、位置、角度を変えるための構造体のようです。
CG系の機能はまだ概念すらつかめていません。
しかも、各向きをサポートすると、初期のviewアウトレットも向きに合わせて設定すべきかと思いますが、工夫して実装しないと固定のようです(Files'Ornerのviewアウトレットの指定のみではだめ)。
回転系の機能はちょっと後回しですね......
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if(toInterfaceOrientation == UIInterfaceOrientationPortrait){
self.view =self.portrait;
self.view.transform = CGAffineTransformIdentity;
self.view.transform = CGAffineTransformMakeRotation(degreesToRadians(0));
self.view.bounds = CGRectMake(0.0, 0.0, 300.0, 480.0);
}
else if(...
}
}
2010年5月2日日曜日
UIViewクラス(ビュー基底クラス)
インスタンスを生成する
– (id)initWithFrame:(CGRect)aRect- 指定されたフレームの矩形(aRect)で、新しく割り当てられたビューオブジェクトを初期化する。
属性の設定し取得するuserInteractionEnabledproperty境界と矩形フレームを変更するframepropertyboundspropertycenterpropertytransformpropertyビュー階層を管理するsuperviewpropertysubviewspropertywindowproperty– (void)addSubview:(UIView*)viewこのメソッドは、レシーバのサブビューとして他のサブビューの最上階層に設定する。レシーバはviewを保持する。そのため、view をビュー階層から削除するにはremoveFromSuperviewでview をリリースする。ビューの交換等のため保持したい場合はそれより前にビューを保持する必要がある。– bringSubviewToFront:– sendSubviewToBack:– removeFromSuperview:– insertSubview:atIndex:– insertSubview:aboveSubview:– insertSubview:belowSubview:– exchangeSubviewAtIndex:withSubviewAtIndex:– isDescendantOfView:座標を変換する– convertPoint:toView:– convertPoint:fromView:– convertRect:toView:– convertRect:fromView:サブビューの大きさを変更するautoresizesSubviewspropertyautoresizingMaskproperty– sizeThatFits:– sizeToFitcontentModepropertycontentStretchpropertyビューの検索NSInteger tagpropertyレシーバのタグであり、アプリケーションからビューオブジェクトを識別する場合にしようする。– (UIView *)viewWithTag:(NSInteger)tagタグで識別されるビューを返す。ビューをレイアウトする– setNeedsLayout– layoutIfNeeded– layoutSubviews表示(非表示)するclipsToBoundspropertybackgroundColorpropertyalphapropertyopaquepropertyclearsContextBeforeDrawingproperty– drawRect:– setNeedsDisplay– setNeedsDisplayInRect:+ layerClasslayerpropertyhiddenpropertyビューをアニメーション表示する+ beginAnimations:animatedID context:contextanimationIDアプリケーション側で設定するブロック内の識別子。setAnimationWillStartSelector:やsetAnimationDidStopSelector:メソッドでアニメーションの依頼メッセージを受け渡す場合に使用する。そうでない場合はnillcontextアプリケーション側で設定する情報。同上。+ commitAnimations+ setAnimationStartDate:+ setAnimationsEnabled:+ setAnimationDelegate:+ setAnimationWillStartSelector:+ setAnimationDidStopSelector:+ setAnimationDuration:アニメーションブロック内でアニメーションを変化させる継続時間(秒)を設定する。+ setAnimationDelay:+ setAnimationCurve:- UIViewAnimationCurveEaseInOut ゆっくり始まり中央で加速しゆっくり終る
- UIViewAnimationCurveEaseIn ゆっくり始まり途中で加速する
- UIViewAnimationCurveEaseOut 速くはじまりゆっくり終る
- UIViewAnimationCurveLinear 同じ速度でアニメーションする
+ setAnimationRepeatCount:+ setAnimationRepeatAutoreverses:+ setAnimationBeginsFromCurrentState:+ setAnimationTransition:forView:cache:
UIViewAnimationTransitionNone 推移しない
UIViewAnimationTransitionFlipFromLeft 垂直軸で左が上に、右が下に推移する
UIViewAnimationTransitionFlipFromRight 垂直軸で右が上に、左が下に推移する
UIViewAnimationTransitionCurlUp 上から下に巻く様に推移する
UIViewAnimationTransitionCurlDown 下から上に巻く様に推移する
+ areAnimationsEnabledイベントを管理する– hitTest:withEvent:– pointInside:withEvent:multipleTouchEnabledpropertyexclusiveTouchproperty– endEditing:ジェスチャーマネージャ(recognizer)を管理する– addGestureRecognizer:– removeGestureRecognizer:gestureRecognizersproperty変更を参照する– didAddSubview:– didMoveToSuperview– didMoveToWindow– willMoveToSuperview:– willMoveToWindow:– willRemoveSubview:
登録:
投稿 (Atom)