ã¯ããã«
ãååã¾ã§ã«Swiftã®åºæ¬çãªææ³ã¨ã¯ã©ã¹ã®ä½¿ãæ¹ã«ã¤ãã¦èª¬æãã¾ãããé£è¼ç¬¬4åã§ã¯ãå®éã«ã¢ããªã®ç»é¢ãä½æããæ¹æ³ã«ã¤ãã¦èª¬æãã¾ãã
ã対象èªè ãObjective-Cãåããæ¹ã¨ãã¦ããé¢ä¿ä¸ãObjective-Cèªä½ã®è¨èªä»æ§ãXcodeã®ä½¿ãæ¹ã«ã¤ãã¦ã¯è§£èª¬ãå²æããå ´åããããã¨ããäºæ¿ãã ãããåæ§ã«Swiftèªä½ã®èª¬æãå¿ ãããååã§ãªãå ´åãããã¾ãããã®ãããªå ´åã¯æ«å°¾ã®åèæç®çãåç §ãã¦ãã ããã
対象èªè
ãæ¬è¨äºã¯ã次ã®æ¹ã対象ã«ãã¦ãã¾ãã
- Objective-Cã®åºæ¬çãªããã°ã©ã ãåºæ¥ãæ¹
- Xcodeã使ããæ¹
ç»é¢ã®æ§æ
ãiOSã¢ããªã®éçºã¯ãç°¡åã«è¨ãã¨ç»é¢ã®ä¸ã«ç»åãããã¹ããªã©ã®ã³ã³ãã³ããé ç½®ãã¦é²ãã¾ããç»é¢ã®ä¸ã«é ç½®ãã¦è¡¨ç¤ºããã¨ããåºå¹¹ã®ã¯ã©ã¹ã¯UIViewã¯ã©ã¹ã§ããããã¦ç»é¢ä¸ã«é ç½®ãããã³ã³ãã³ãã¯å ¨ã¦UIViewã¯ã©ã¹ã®æ´¾çã¯ã©ã¹ã§ãã
ãã¥ã¼ã®ä½ç½®é¢ä¿
ãiOSã¢ããªã§ã¯ãç»é¢ã®å·¦ä¸ã®é ç¹ã(0, 0)ã¨ãã¦ç»é¢å ã®ä½ç½®é¢ä¿ãèãã¾ããç»é¢ä¸ã«é ç½®ããã³ã³ãã³ãã¯ã次ã®3ã¤ã®æ§é ä½ã§ä½ç½®ã¨ãµã¤ãºã管çãã¾ãã
åå | æ¦è¦ | çæããé¢æ° |
---|---|---|
GGPoint | ç»é¢å ã®ä½ç½®ã管çããæ§é ä½ | CGPointMake(横ä½ç½®, 縦ä½ç½®) |
CGSize | ãµã¤ãºã管çããæ§é ä½ | CGSizeMake(æ¨ªå¹ , ç¸¦å¹ ) |
CGRect | ä½ç½®ã¨ãµã¤ãºã®ä¸¡æ¹ã管çããæ§é ä½ | CGRectMake(横ä½ç½®, 縦ä½ç½®, æ¨ªå¹ , ç¸¦å¹ ) |
ã3ã¤ã®æ§é ä½ã®é¢ä¿ã¯æ¬¡ã®å³ã®éãã§ãã
ãå ·ä½çãªå©ç¨ã®ä¾ã«ã¤ãã¦ã¯ã次ç¯ã®ãµã³ãã«ã§ç¢ºèªã§ãã¾ããã¾ããç»é¢ä¸ã®ä½ç½®é¢ä¿ãç»é¢å ¨ä½ããè¦ãå ´åã¨ãã¼ã«ã«ã®ä½ç½®ããè¦ãå ´åã®2éãã§æ±ããããããã£ãç¨æããã¦ãã¾ãã
åå | æ¦è¦ |
---|---|
frame | 親ã¨ãªããã¥ã¼ããè¦ãéã®åº§æ¨ç³»ã®ä½ç½®ã¨ãµã¤ãº |
bounds | èªåèªèº«ã®ãã¼ã«ã«åº§æ¨ç³»ã®ä½ç½®ã¨ãµã¤ãº |
ãä»åã®ãµã³ãã«ã§å©ç¨ããã¯ã©ã¹ï¼ãã¡ã¤ã«ã¯æ¬¡ã®éãã§ãã
åå | å½¹å² | ãµã³ãã«å ã®è©²å½ãããã¡ã¤ã« |
---|---|---|
AppDelegate | ã¢ããªã管çããæä¸ä½ã®ã¯ã©ã¹ | AppDelegate.swift |
ãã¥ã¼ã³ã³ããã¼ã©ã¼ | ç»é¢ã管çããã¯ã©ã¹ | ViewController.swift |
xlib | InterfaceBuiderã§çæããç»é¢ã®UI | SampleViewController.xib |