macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

attributedText

INDEX>UIKit>UITextField

属性付きテキスト

Objective-C

@property(nonatomic, copy) NSAttributedString *attributedText

Swift

@NSCopying var attributedText: NSAttributedString?

解説

テキストフィールドの属性付きテキスト。
f:id:jjj777:20150215140615p:plain

属性付きテキストを使用することで、部分的に色を変えたり、フォントやフォントサイズを変えることが出来ます。

設定値

Objective-C

@property(nonatomic, copy) NSAttributedString *attributedText

Swift

@NSCopying var attributedText: NSAttributedString?

クラス

UITextField

使用可能

iOS6.0

参照

NSAttributedString
UIFont
UIColor

関連記事(外部サイト)

例文

Objective-C

Swift
f:id:jjj777:20150215140615p:plain

@IBOutlet weak var defaultTF: UITextField!
    //UITextField attributedText
    @IBAction func function003(sender: AnyObject) {
        var attrs = [NSForegroundColorAttributeName: UIColor.redColor(),
                        NSFontAttributeName : UIFont.systemFontOfSize(19.0)]
        var aText : NSAttributedString = NSAttributedString(string: "属性付き文字",
                                            attributes: attrs)
        defaultTF.attributedText = aText
    }

UICollectionViewクラス

INDEX>UIKit>

apple

行、列でアイテムを配置して表示できるビュー
継承 UIScrollView : UIView : UIResponder : NSObject
準拠 NSCoding (UIScrollView)
NSCoding (UIView)
UIAppearance (UIView)
UIAppearanceContainer (UIView)
NSObject (NSObject)
フレームワーク /System/Library/Frameworks/UIKit.framework
使用可能 iOS 6.0以降
定義 UICollectionView.h

概要

行、列でアイテムを配置して表示できるビュー

メソッドとプロパティ

コレクションビューの初期化

– initWithFrame:collectionViewLayout:

コレクションビューの設定

collectionViewLayout property
– setCollectionViewLayout:animated:
delegate property
dataSource property
backgroundView property

コレクションビューの状態の取得

– numberOfSections
– numberOfItemsInSection
– visibleCells

セクションの挿入、移動、除去

– insertSections
– moveSection:toSection
– deleteSections

ビューでアイテムのスクロール

– scrollToItemAtIndexPath:atScrollPosition:animated

コレクションビューの同時の変更

– performBatchUpdates:completion

クラス

UICollectionView

参照

NSShadowクラス

INDEX>UIKit>

apple

継承 NSObject
準拠 NSObject (NSObject)
フレームワーク /System/Library/Frameworks/UIKit.framework
使用可能 iOS 6.0以降
定義 NSShadow.h

概要

メソッドとプロパティ

シャドウの管理

shadowOffset property
shadowBlurRadius property
shadowColor property

クラス

NSShadow

参照

UIViewクラス

INDEX>UIKit>UIView

描画とイベントを扱う実体サブクラスを提供するための抽象クラス

apple

解説

UIViewクラスは描画とイベントを扱う実体サブクラスを提供するための抽象クラスです。

継承 UIResponder : NSObject
準拠 NSCoding
UIAppearance
UIAppearanceContainer
NSObject (NSObject)
フレームワーク /System/Library/Frameworks/UIKit.framework
使用可能 iOS 2.0以降
定義 UIView.h

概要

UIViewクラスは描画とイベントハンドリング構造の実体サブクラスを提供するための抽象クラスです。
他のビューを含むUIViewの実体インスタンスを作ることができます。


UIViewオブジェクトはUIWindowオブジェクトの中にサブビューの階層を持って配置されます。

ビュー階層の中で親オブジェクトはスーパービュー(superview)と呼ばれます。そして子オブジェクトはサブビュー(subview)と呼ばれます。


ビューオブジェクトはスーパービューの中で矩形領域を要求します、それはその領域でのすべての描画に責任があり、その上発生するイベントを受け取る資格があります。

兄弟ビューは問題なく重ねることができます。複雑なビューの配置ができます。

UIViewはビュー、UIViewControllerがビューをコントロールします。

Xcode5

Constraints:自動レイアウトの制限事項
Width Constraint:幅の制限


Relation:
Constant:
Priority:
Placeholder:

使用可能

iOS 2.0以降

メソッドとプロパティ

アトリビュートのセットとゲット

userInteractionEnabled property

矩形とフレーム矩形の修正

frame property
bounds property
center property
transform property

サブビューのリサイジング

autoresizesSubviews property
autoresizingMask property
– sizeThatFits
– sizeToFit
contentMode property
contentStretch property

ビューの検索

tag property
– viewWithTag:

UIApplicationクラス

INDEX>UIKit>UIApplication

アプリケーションクラス

apple

解説

iPhone/iPadアプリケーションのクラスです。

継承 UIResponder : NSObject
準拠 NSObject (NSObject)
フレームワーク /System/Library/Frameworks/UIKit.framework
使用可能 iOS 2.0 以降
定義 UIApplication.h

概要

UIApplicationクラスは集中管理のポイントとiOSでのアプリケーションの実行調整を提供します。
すべてのアプリケーションはただ一つのUIApplication(またはそのサブクラス)のインスタンスを持たなければなりません。
アプリケーションが起動するとき、UIApplication関数が呼ばれます。

他のタスクの間で、この関数はシングルトンUIApplicationオブジェクトを作ります。
その後、+sharedApplicationクラスメソッドを起動してこのオブジェクトにアクセスすることができます。
UIAppicationオブジェクトの主な役割は、ユーザーイベントが到着したときイベントを振り分けます。

サブクラス化の注意

UIApplicationのサブクラスが -sendEvent: -sendAction:to:from:forEvent: の実装がカスタムイベントやアクションをオーバーライドするか決定しなければならない。

使用可能

iOS 2.0以降

メソッドとプロパティ

アプリケーションのインスタンスを得る

+ sharedApplication
 シングルトンアプリケーションインスタンスを返します。

アプリケーションのウインドウを得る

keyWindow property
 アプリケーションのキーウインドウ
windows property

デフォルトのインターフェースの向きの管理

– supportedInterfaceOrientationsForWindow:

URLリソースのオープン

– openURL:
 指定したURLを開きます。
– canOpenURL
 与えられたURLリソースがアプリケーションで開くことができるかを返します。

アプリケーションアクティビティの管理

idleTimerDisabled property
 自動スリープするか

Performing State Restoration Asynchronously

– extendStateRestoration
– completeStateRestoration

Determining the Availability of Protected Content

protectedDataAvailable property

リモート・コントロールイベントの登録

– beginReceivingRemoteControlEvents
– endReceivingRemoteControlEvents

アプリケーションアピアランスの管理

– setStatusBarHidden:animated:
statusBarHidden property
– setStatusBarStyle:animated:
statusBarStyle property
statusBarFrame property
networkActivityIndicatorVisible property
applicationIconBadgeNumber property
 スプリングボードでのアイコンバッチ番号

デリゲートのセットとゲット

delegate property

通知

UIApplicationDidBecomeActiveNotification
アプリケーションがアクティブになる通知
UIApplicationDidChangeStatusBarFrameNotification
ステータスバーのサイズが変更になった時に通知。向きが変わった時など

UIApplicationDidFinishLaunchingNotification
アプリケーションが起動しようとする通知

UIApplicationDidReceiveMemoryWarningNotification
メモリ不足の警告を通知

UIApplicationSignificantTimeChangeNotification
時間に変更があった場合の通知

UIApplicationWillChangeStatusBarOrientationNotification
デバイスの向きが変わろうとするときに通知

UIApplicationDidChangeStatusBarOrientationNotification
デバイスの向きが変わった後に通知

UIApplicationWillChangeStatusBarFrameNotification
ステータスバーのサイズが変更される直前に通知

UIApplicationWillResignActiveNotification
アプリケーションがアクティブでなくなろうとするときに通知

UIApplicationWillTerminateNotification
アプリケーションが終了しようとする通知