最終更新:2013-01-11 (金) 03:06:10 (2348d)  

UIView はてなブックマークを見る
Top / UIView

画面表示を管理するクラス

http://developer.apple.com/library/ios/#documentation/uikit/reference/uiview_class/uiview/uiview.html

Tasks

Initializing a View Object

  • initWithFrame?

Configuring a View’s Visual Appearance

  • backgroundColor? - property - (UIColor)
  • hidden? - property - (BOOL)
  • alpha? - property - (CGFloat)
  • opaque? - property - (BOOL)
  • clipsToBounds? - property - (BOOL)
  • clearsContextBeforeDrawing? - property - (BOOL)
  • +layerClass?
  • layer? - property - (CALayer?)

Configuring the Event-Related Behavior

  • userInteractionEnabled? - property - (BOOL)
  • multipleTouchEnabled? - property - (BOOL)
  • exclusiveTouch? - property - (BOOL)

Configuring the Bounds and Frame Rectangles

Managing the View Hierarchy

  • superview? - property - (UIView)
  • subviews? - property - (NSArray)
  • window - property - (UIWindow)
  • addSubview?
  • bringSubviewToFront?
  • sendSubviewToBack?
  • removeFromSuperview?
  • insertSubview:atIndex?
  • insertSubview:aboveSubview?
  • insertSubview:belowSubview?
  • exchangeSubviewAtIndex:withSubviewAtIndex?
  • isDescendantOfView?

Configuring the Resizing Behavior

  • autoresizingMask? - property - (UIViewAutoresizing?)
  • autoresizesSubviews? - property - (BOOL)
  • contentMode? - property - (UIViewContentMode?)
  • sizeThatFits?
  • sizeToFit?
  • contentStretch? - property - (CGRect) Deprecated in iOS 6.0

Laying out Subviews

  • layoutSubviews?
  • setNeedsLayout?
  • layoutIfNeeded?

Opting in to Constraint-Based Layout

  • +requiresConstraintBasedLayout?
  • translatesAutoresizingMaskIntoConstraints?
  • setTranslatesAutoresizingMaskIntoConstraints?

Managing Constraints

  • constraints?
  • addConstraint?
  • addConstraints?
  • removeConstraint?
  • removeConstraints?

Measuring in Constraint-Based Layout

  • systemLayoutSizeFittingSize?
  • intrinsicContentSize?
  • invalidateIntrinsicContentSize?
  • contentCompressionResistancePriorityForAxis?
  • setContentCompressionResistancePriority:forAxis?
  • contentHuggingPriorityForAxis?
  • setContentHuggingPriority:forAxis?

Aligning Views with Constraint-Based Layout

  • alignmentRectForFrame?
  • frameForAlignmentRect?
  • alignmentRectInsets?
  • viewForBaselineLayout?

Triggering Constraint-Based Layout

  • needsUpdateConstraints?
  • setNeedsUpdateConstraints?
  • updateConstraints?
  • updateConstraintsIfNeeded?

Debugging Constraint-Based Layout

  • constraintsAffectingLayoutForAxis?
  • hasAmbiguousLayout?
  • exerciseAmbiguityInLayout?

Drawing and Updating the View

Formatting Printed View Content

  • viewPrintFormatter?
  • drawRect:forViewPrintFormatter?

Managing Gesture Recognizers

  • addGestureRecognizer?
  • removeGestureRecognizer?
  • gestureRecognizers? - property - (NSArray)
  • gestureRecognizerShouldBegin?

Animating Views with Blocks

  • +animateWithDuration:delay:options:animations:completion?
  • +animateWithDuration:animations:completion?
  • +animateWithDuration:animations?
  • +transitionWithView:duration:options:animations:completion?
  • +transitionFromView:toView:duration:options:completion?

Animating Views

  • Use of the methods in this section is discouraged in iOS 4 and later. Use the block-based animation methods instead.
  • +beginAnimations:context?
  • +commitAnimations?
  • +setAnimationStartDate?
  • +setAnimationsEnabled?
  • +setAnimationDelegate?
  • +setAnimationWillStartSelector?
  • +setAnimationDidStopSelector?
  • +setAnimationDuration?
  • +setAnimationDelay?
  • +setAnimationCurve?
  • +setAnimationRepeatCount?
  • +setAnimationRepeatAutoreverses?
  • +setAnimationBeginsFromCurrentState?
  • +setAnimationTransition:forView:cache?
  • +areAnimationsEnabled?

Preserving and Restoring State

  • restorationIdentifier? - property - (NSString)
  • encodeRestorableStateWithCoder?
  • decodeRestorableStateWithCoder?

Identifying the View at Runtime

Converting Between View Coordinate Systems

  • convertPoint:toView?
  • convertPoint:fromView?
  • convertRect:toView?
  • convertRect:fromView?

Hit Testing in a View

  • hitTest:withEvent?
  • pointInside:withEvent?

Ending a View Editing Session

  • endEditing?

Observing View-Related Changes

  • didAddSubview?
  • willRemoveSubview?
  • willMoveToSuperview?
  • didMoveToSuperview?
  • willMoveToWindow?
  • didMoveToWindow?

描画

  • UIViewのサブクラスを作成して
- (void)drawRect:(CGRect)rect {
    // Drawing code
    // グラフィックコンテキスト取得

    CGContextRef context = UIGraphicsGetCurrentContext();

    // CoreGraphicsの原点が左下なので原点を合わせる
    CGContextTranslateCTM(context, 0, rect.size.height);
    CGContextScaleCTM(context, 1.0, -1.0);

    // 線の色を R,G,B,A で設定
    CGContextSetRGBStrokeColor(context, 0.0, 1.0, 0.0, 1.0);
    // 線の太さ
    CGContextSetLineWidth(context, 10);

    // Pathを作成
    CGContextBeginPath(context);
    // Pathの位置設定
    CGContextMoveToPoint(context, 100.0, 100.0);
    CGContextAddLineToPoint(context, 50.0, 150.0);
    CGContextAddLineToPoint(context, 100.0, 150.0);
    // Pathの描画
    CGContextDrawPath(context, kCGPathStroke);

    NSString* str = [NSString stringWithFormat:@"Elapsed time: %f", -elapsedTime]; 
    UIFont *font = [UIFont systemFontOfSize:24];
    [[UIColor whiteColor] set];//色
    [str drawAtPoint:CGPointMake(0,0) withFont:font];
}
  • UIGraphicsGetCurrentContext?
  • CGContextRef?

再描画

メモ

  • 概念上は、iPhone OSのウインドウとビューは、Mac OS Xの場合と同様に同じ構成体を表しています。しかし、実装の観点では、この2つのプラットフォームはウインドウとビューをまったく異なった方法で実装しています。Mac OS Xでは、NSWindowクラスはNSResponderのサブクラスですが、iPhone OSでは、UIWindowクラスは実際はUIViewのサブクラスです。この継承関係の違いは、ウインドウがCore Animationレイヤを使用して描画サーフェスを実現していることを意味します。UIKitのすべてでウインドウオブジェクトを持つ理由は、オペレーティングシステム内でウインドウのレイヤ化をサポートするためです。

下位クラス

関連