導航:首頁 > 編程語言 > iosui編程

iosui編程

發布時間:2024-05-17 12:45:22

A. ios ui鎵嬪啓浠g爜鏄浠涔堣璦

銆鍘熺悊錛欼OS6.0 涔嬪悗錛岃嫻鏋滀紭鍖栦簡UI鐣岄潰鐨勫竷灞鏂瑰紡錛屾彁鍑轟簡鑷鍔ㄥ竷灞鐨勬傚康錛屽拰涔嬪墠鐨刟utoresizing鐩告瘮鍔熻兘鏇村己澶с傚瓙瑙嗗浘鍩轟簬鐖惰嗗浘鐨勮嚜鍔ㄥ竷灞鏄劇ず銆傞兘鏄鐖惰嗗浘鍘繪坊鍔犲瑰瓙瑙嗗浘鐨勭害鏉熴
銆銆鍦ㄨ繖閲屼富瑕佽寸殑鏄閫氳繃浠g爜瀵硅嚜鍔ㄥ竷灞瑙嗗浘鐨勫疄鐜般
銆銆浠g爜涓涓鑸鐢ㄥ埌鐨勬湁涓や釜娣誨姞綰︽潫鐨勬柟寮忥細
銆銆1.- (void)addConstraint:(NSLayoutConstraint *)constraint NS_AVAILABLE_IOS(6_0);
銆銆2.- (void)addConstraints:(NSArray *)constraints NS_AVAILABLE_IOS(6_0);
銆銆<</span>
銆銆鍦ㄤ嬌鐢ㄨ嚜鍔ㄥ竷灞涔嬪墠瑕佸瑰瓙瑙嗗浘鐨勫竷灞鏂瑰紡榪涜岃皟鏁達紝鐢ㄥ埌榪欎釜UIView鐨勫睘鎬с
銆銆- (BOOL) NS_AVAILABLE_IOS(6_0); // Default YES
銆銆闇瑕佸皢鍏惰劇疆涓篘O錛
銆銆>
銆銆涓嬮潰鐢ㄧ畝鍗曚緥瀛愯存槑涓涓嬶細
銆銆UIView *v1 = [[UIView alloc] initWithFrame:CGRectZero];
銆銆v1. = NO;
銆銆v1.backgroundColor = [UIColor redColor];
銆銆[self.view addSubview:v1];

銆銆UIView *v2 = [[UIView alloc] initWithFrame:CGRectZero];
銆銆v2.backgroundColor = [UIColor grayColor];
銆銆v2. = NO;
銆銆[self.view addSubview:v2];//娣誨姞涓や釜鍏佽歌嚜鍔ㄥ竷灞鐨勫瓙瑙嗗浘
銆銆
銆銆[self.view addConstraint:[NSLayoutConstraint constraintWithItem:v1
銆銆attribute:NSLayoutAttributeWidth
銆銆relatedBy:NSLayoutRelationEqual
銆銆toItem:self.view
銆銆attribute:NSLayoutAttributeWidth
銆銆multiplier:1.0
銆銆constant:0]];//璁劇疆瀛愯嗗浘鐨勫藉害鍜岀埗瑙嗗浘鐨勫藉害鐩稿悓

銆銆[self.view addConstraint:[NSLayoutConstraint constraintWithItem:v1
銆銆attribute:NSLayoutAttributeHeight
銆銆relatedBy:NSLayoutRelationEqual
銆銆toItem:self.view
銆銆attribute:NSLayoutAttributeHeight
銆銆multiplier:0.5
銆銆constant:0]];//璁劇疆瀛愯嗗浘鐨勯珮搴︽槸鐖惰嗗浘楂樺害鐨勪竴鍗

銆銆[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[v1][v2(==v1)]-0-|" options:0 metrics:nil views:views]];//閫氳繃addConstraints 娣誨姞瀵規按騫蟲柟鍚戜笂v1鐨勬帶鍒--璺濈葷埗瑙嗗浘宸︿晶璺濈諱負0錛堣窛紱諱負0鐨勮瘽涔熷彲鐪佺暐錛夊悓鏃跺皢v2鐨勬按騫蟲柟鍚戠殑瀹藉害鍜寁1璁劇疆鎴愮浉鍚
銆銆
銆銆[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[v1][v2(==v1)]|" options:0 metrics:nil views:views]];/閫氳繃addConstraints 娣誨姞瀵瑰瀭鐩存柟鍚戜笂v1鐨勬帶鍒--璺濈葷埗瑙嗗浘涓婁晶璺濈諱負0錛堣窛紱諱負0鐨勮瘽涔熷彲鐪佺暐錛夊悓鏃跺皢v2鐨勫瀭鐩存柟鍚戠殑楂樺害鍜寁1璁劇疆鎴愮浉鍚
銆銆
銆銆[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[v1]-0-[v2]-0-|" options:0 metrics:nil views:views]];//鏈鍚庢槸鍨傜洿甯冨矓涓や釜瀛恦iew
銆銆榪欐牱灝卞彲浠ュ疄鐜頒笂涓嬩袱涓獀iew錛屽悇鍗犱竴鍗娿傛棆杞灞忓箷鐨勬儏鍐典笅涔熶細鑷鍔ㄥ勭悊甯冨矓銆傝繖鏍風湅璧鋒潵浠g爜澶氾紝浣嗘槸鍙浠ラ傚簲澶氱嶅垎杈ㄧ巼鐨勫睆騫曘備笉鎺掗櫎浠ュ悗鑻規灉鍑烘洿澶ф洿澶氬垎杈ㄧ巼鐨勬墜鏈恆

銆銆鍏充簬constraintsWithVisualFormat錛氬嚱鏁頒粙緇嶏細
銆銆
銆銆constraintsWithVisualFormat:鍙傛暟涓篘SString鍨嬶紝鎸囧畾Contsraint鐨勫睘鎬э紝鏄鍨傜洿鏂瑰悜鐨勯檺瀹氳繕鏄姘村鉤鏂瑰悜鐨勯檺瀹氾紝鍙傛暟瀹氫箟涓鑸濡備笅錛
銆銆V:|-(>=XXX) :琛ㄧず鍨傜洿鏂瑰悜涓婄浉瀵逛簬SuperView澶т簬銆佺瓑浜庛佸皬浜庢煇涓璺濈
銆銆鑻ユ槸瑕佸畾涔夋按騫蟲柟鍚戱紝鍒欏皢V錛氭敼鎴怘錛氬嵆鍙
銆銆鍦ㄦ帴鐫鍚庨潰-[]涓鎷鍙烽噷闈㈠瑰綋鍓嶇殑View/鎺т歡 鐨勯珮搴/瀹藉害榪涜岃懼畾錛
銆銆options錛氬瓧鍏哥被鍨嬬殑鍊礆紱榪欓噷鐨勫間竴鑸鍦ㄧ郴緇熷畾涔夌殑涓涓猠num閲岄潰閫夊彇
銆銆metrics錛歯il錛涗竴鑸涓簄il 錛屽弬鏁扮被鍨嬩負NSDictionary錛屼粠澶栭儴浼犲叆 //琛¢噺鏍囧噯
銆銆views錛氬氨鏄涓婇潰鎵鍔犲叆鍒癗SDictionary涓鐨勭粦瀹氱殑View
銆銆鍦ㄨ繖閲岃佹敞鎰忕殑鏄 AddConstraints 鍜 AddConstraint 涔嬮棿鐨勫尯鍒錛屼竴涓娣誨姞鐨勫弬鏁版槸NSArray錛屼竴涓鏄疦SLayoutConstraint
銆銆浣跨敤瑙勫垯

銆銆|: 琛ㄧず鐖惰嗗浘
銆銆-:琛ㄧず璺濈
銆銆V: :琛ㄧず鍨傜洿
銆銆H: :琛ㄧず姘村鉤
銆銆>= :琛ㄧず瑙嗗浘闂磋窛銆佸藉害鍜岄珮搴﹀繀欏誨ぇ浜庢垨絳変簬鏌愪釜鍊
銆銆<= :琛ㄧず瑙嗗浘闂磋窛銆佸藉害鍜岄珮搴﹀繀欏誨皬瀹囨垨絳変簬鏌愪釜鍊
銆銆== :琛ㄧず瑙嗗浘闂磋窛銆佸藉害鎴栬呴珮搴﹀繀欏葷瓑浜庢煇涓鍊
銆銆@ :>=銆<=銆== 闄愬埗 鏈澶т負 1000

銆銆1.|-[view]-|: 瑙嗗浘澶勫湪鐖惰嗗浘鐨勫乏鍙寵竟緙樺唴
銆銆2.|-[view] : 瑙嗗浘澶勫湪鐖惰嗗浘鐨勫乏杈圭紭
銆銆3.|[view] : 瑙嗗浘鍜岀埗瑙嗗浘宸﹁竟瀵歸綈
銆銆4.-[view]- : 璁劇疆瑙嗗浘鐨勫藉害楂樺害
銆銆5.|-30.0-[view]-30.0-|: 琛ㄧず紱葷埗瑙嗗浘 宸﹀彸闂磋窛 30
銆銆6.[view(200.0)] : 琛ㄧず瑙嗗浘瀹藉害涓 200.0
銆銆7.|-[view(view1)]-[view1]-| :琛ㄧず瑙嗗浘瀹藉害涓鏍鳳紝騫朵笖鍦ㄧ埗瑙嗗浘宸﹀彸杈圭紭鍐
銆銆8. V:|-[view(50.0)] : 瑙嗗浘楂樺害涓 50
銆銆9: V:|-(==padding)-[imageView]->=0-[button]-(==padding)-| : 琛ㄧず紱葷埗瑙嗗浘鐨勮窛紱
銆銆涓篜adding,榪欎袱涓瑙嗗浘闂磋窛蹇呴』澶т簬鎴栫瓑浜0騫朵笖璺濈誨簳閮ㄧ埗瑙嗗浘涓 padding銆
銆銆10: [wideView(>=60@700)] :瑙嗗浘鐨勫藉害涓鴻嚦灝戜負60 涓嶈兘瓚呰繃 700
銆銆11: 濡傛灉娌℃湁澹版槑鏂瑰悜榛樿や負 姘村鉤 V:

B. ios寮鍙憉iwindow uitextfield浠g悊鎬庝箞瀹炵幇

鏂囬《欏

iOS寮鍙慤I綃団擴IWindow綆鍗曚粙緇

iOS寮鍙慤I綃団擴IWindow綆鍗曚粙緇

涓銆佺畝鍗曚粙緇

UIWindow鏄涓縐嶇壒孌婄殑UIView錛岄氬父鍦ㄤ竴涓猘pp涓鍙浼氭湁涓涓猆IWindow

iOS紼嬪簭鍚鍔ㄥ畬姣曞悗錛屽壋寤虹殑絎涓涓瑙嗗浘鎺т歡灝辨槸UIWindow錛屾帴鐫鍒涘緩鎺у埗鍣ㄧ殑view錛屾渶鍚庡皢鎺у埗鍣ㄧ殑view娣誨姞鍒癠IWindow涓婏紝浜庢槸鎺у埗鍣ㄧ殑view灝辨樉紺哄湪灞忓箷涓婁簡

涓涓猧OS紼嬪簭涔嬫墍浠ヨ兘鏄劇ず鍒板睆騫曚笂錛屽畬鍏ㄦ槸鍥犱負瀹冩湁UIWindow銆備篃灝辮達紝娌℃湁UIWindow錛屽氨鐪嬩笉瑙佷換浣昒I鐣岄潰

琛ュ厖錛歎IWindow鏄鍒涘緩鐨勭涓涓瑙嗗浘鎺т歡錛堝壋寤虹殑絎涓涓瀵硅薄鏄疷Iapplication錛夊備笅鍥撅細

娣誨姞

鍏堝壋寤篣Iwindow,鍐嶅壋寤烘帶鍒跺櫒錛屽壋寤烘帶鍒跺櫒鐨剉iew錛岀劧鍚庡皢鎺у埗鍣ㄧ殑view娣誨姞鍒癠IWindow涓娿

鏂囨。涓鍏充簬璇ラ儴鍒嗙殑瑙i噴錛

浜屻乁IWindow鐨勫壋寤鴻繃紼

1.綆鍗曡存槑

鍒涘緩涓涓絀虹殑欏圭洰錛屽氨鍙浠ョ湅鍒癠IWindow鏄鎬庝箞鍑烘潵鐨勪簡銆傚湪紼嬪簭鍚鍔ㄥ畬姣曚箣鍚庡氨浼氳皟鐢ㄤ竴嬈★紝鍒涘緩榪囩▼濡備笅錛

鎻愮ず錛氬簲鐢ㄧ▼搴忓惎鍔ㄤ箣鍚庯紝鍏堝壋寤篈pplication錛屽啀鍒涘緩瀹冪殑浠g悊錛屼箣鍚庡壋寤篣Iwindow銆俇IWindow緇ф壙鑷猆Iview銆

2.鎶妚iew娣誨姞鍒皍iwindow

鍒涘緩涓涓鎺у埗鍣錛屾妸view娣誨姞鍒皍iwindow涓婇潰錛堟湁涓ょ嶆柟寮忥級

錛1錛夌洿鎺ュ皢鎺у埗鍣ㄧ殑view娣誨姞鍒癠IWindow涓錛屽苟涓嶇悊浼氬畠瀵瑰簲鐨勬帶鍒跺櫒

[self.window addsubview:vc.view];

錛2錛夎劇疆uiwindow鐨勬牴鎺у埗鍣錛岃嚜鍔ㄥ皢rootviewcontroller鐨剉iew娣誨姞鍒皐indow涓錛岃礋璐g$悊rootviewcontroller鐨勭敓鍛藉懆鏈

[self.window.rootviewcontroller=vc];

涓や釜鏂規硶鐨勫尯鍒錛

浠ュ悗鐨勫紑鍙戜腑錛屽緩璁浣跨敤錛2錛.鍥犱負鏂規硶錛1錛夊瓨鍦ㄤ竴浜涢棶棰橈紝姣斿傝存帶鍒跺櫒涓婇潰鍙鑳界敱鎸夐挳錛岄渶瑕佺洃鍚鎸夐挳鐨勭偣鍑諱簨浠訛紝濡傛灉鏄1錛岄偅涔堟寜閽鐨勪簨浠跺簲璇ョ敱鎺у埗鍣ㄦ潵榪涜岀$悊銆備絾鎺у埗鍣ㄦ槸涓涓灞閮ㄥ彉閲忥紝鎺у埗鍣ㄦゆ椂宸茬粡涓嶅瓨鍦ㄤ簡錛屼絾鏄鎺у埗鍣ㄧ殑view榪樺湪錛屾ゆ椂鏈夊彲鑳戒細鎶ラ敊銆傛敞鎰忥細鏂規硶鎵ц屽畬錛岃繖涓鎺у埗鍣ㄥ氨宸茬粡涓嶅瓨鍦ㄤ簡銆

闂棰樻弿榪1錛氬綋view鍙戠敓涓浜涗簨浠剁殑鏃跺欙紝閫氱煡鎺у埗鍣錛屼絾鏄鎺у埗鍣ㄥ凡緇忛攢姣佷簡錛屾墍浠ュ彲鑳藉嚭鐜版湭鐭ョ殑閿欒銆

闂棰樻弿榪2錛氭坊鍔犱竴涓寮鍏蟲寜閽錛岃╁睆騫360搴︽棆杞錛堜袱鑰呯殑鏁堟灉涓嶄竴鏍鳳級銆傚綋鍙戠敓灞忓箷鏃嬭漿浜嬩歡鐨勬椂鍊欙紝UIapplication瀵硅薄浼氬皢鏃嬭漿浜嬩歡浼犻掔粰uiwindow,uiwindow鍙堜細灝嗘棆杞浜嬩歡浼犻掔粰瀹冪殑鏍規帶鍒跺櫒錛岀敱鏍規帶鍒跺櫒鍐沖畾鏄鍚﹂渶瑕佹棆杞

UIapplication->uiwindow->鏍規帶鍒跺櫒錛堢涓縐嶆柟寮忔病鏈夋牴鎺у埗鍣錛屾墍浠ヤ笉鑳借窡鐫鏃嬭漿錛夈

鎻愮ず錛氫笉閫氳繃鎺у埗鍣ㄧ殑view涔熷彲浠ュ仛寮鍙戱紝浣嗘槸鍦ㄥ疄闄呭紑鍙戜腑錛屼笉瑕佽繖涔堝仛錛屼笉瑕佺洿鎺ユ妸view娣誨姞鍒癠IWindow涓婇潰鍘匯傚洜涓猴紝闅句互綆$悊銆

3.鍦ㄦ湁storyboard鐨勯」鐩涓錛孶IWindow鏄濡備綍鍒涘緩鐨勶紵

涓轟粈涔堝壋寤轟竴涓猻toryboard錛屾病鏈夌湅鍒板壋寤簎iwindow鐨勮繃紼嬶紵

瀹冨叾瀹炴槸鎶婂壋寤篣IWindow鐨勮繃紼嬬粰灞忚斀璧鋒潵浜嗐傚彲浠ユ妸浠g悊鐨
UIWindow鐨勫睘鎬х殑鍊兼墦鍗板嚭鏉NSLog(@鈥渨indow=%p鈥,self.window);鎵撳嵃鍑烘潵紜瀹炴槸鏈夊肩殑錛岃存槑紜瀹炲壋寤轟簡
UIWindow.涓嶄粎鍒涘緩浜哢IWindow錛岄粯璁よ繕鍒涘緩浜哢IWindow瀵瑰簲鐨勬帶鍒跺櫒錛屼篃鍙浠ユ墦鍗拌繘琛屾煡鐪嬨
NSLog(@鈥%@鈥,self.window.rootviewcontroller);

鏈塻toryboard鐨勯」鐩涓鐨勫壋寤鴻繃紼嬶細

褰撶敤鎴風偣鍑誨簲鐢ㄧ▼搴忓浘鏍囩殑鏃跺欙紝鍏堟墽琛孧ain鍑芥暟錛屾墽琛
UIApplicationMain錛堬級,鏍規嵁鍏剁涓変釜鍜岀鍥涗釜鍙傛暟鍒涘緩Application錛屽壋寤轟唬鐞嗭紝騫朵笖鎶婁唬鐞嗚劇疆緇檃pplication錛堢湅
欏圭洰閰嶇疆鏂囦歡info.plist閲岄潰鐨剆toryboard鐨刵ame錛屾牴鎹榪欎釜name鎵懼埌瀵瑰簲鐨剆toryboard錛夛紝寮鍚涓涓浜嬩歡寰鐜錛屽綋紼嬪簭
鍔犺澆瀹屾瘯錛屼粬浼氳皟鐢ㄤ唬鐞嗙殑didFinishLaunchingWithOptions:鏂規硶銆傚湪璋冪敤
didFinishLaunchingWithOptions:鏂規硶涔嬪墠錛屼細鍔犺澆storyboard錛屽湪鍔犺澆鐨勬椂鍊欏壋寤轟竴涓獁indow錛屾帴涓嬫潵浼氬壋寤
綆澶存墍鎸囧悜鐨勬帶鍒跺櫒錛屾妸璇ユ帶鍒跺櫒璁劇疆涓篣IWindow鐨勬牴鎺у埗鍣錛屾帴涓嬫潵鍐嶅皢window鏄劇ず鍑烘潵錛屽嵆鐪嬪埌浜嗚繍琛屽悗鏄劇ず鐨勭晫闈銆傦紙鎻愮ず錛氬叧浜庤繖閮ㄥ垎鍙浠
鏌ョ湅story鐨勫垵濮嬪寲鐨勬枃妗o級

涓夈佸備綍鑾峰彇window?

1.涓葷獥鍙e拰嬈$獥鍙

銆恠elf.window makekeyandvisible銆戣╃獥鍙f垚涓轟富紿楀彛錛屽苟涓旀樉紺哄嚭鏉ャ傛湁榪欎釜鏂規硶錛屾墠鑳芥妸淇℃伅鏄劇ず鍒板睆騫曚笂銆

鍥犱負Window鏈塵akekeyandvisible榪欎釜鏂規硶錛屽彲浠ヨ╄繖涓猈indow鍑絀虹殑鏄劇ず鍑烘潵錛岃屽叾浠栫殑view娌℃湁榪欎釜鏂規硶錛屾墍浠ュ畠鍙鑳戒緷璧栦簬Window錛學indow鏄劇ず鍑烘潵鍚庯紝view鎵嶄緷闄勫湪Window涓婃樉紺哄嚭鏉ャ

銆恠elf.window make keywindow銆//璁﹗iwindow鎴愪負涓葷獥鍙o紝浣嗕笉鏄劇ず銆

2.鑾峰彇UIwindow

錛1錛塠UIApplication sharedApplication].windows 鍦ㄦ湰搴旂敤涓鎵撳紑鐨刄IWindow鍒楄〃錛岃繖鏍峰氨鍙浠ユ帴瑙﹀簲鐢ㄤ腑鐨勪換浣曚竴涓猆IView瀵硅薄(騫蟲椂杈撳叆鏂囧瓧寮瑰嚭鐨勯敭鐩橈紝灝卞勫湪涓涓鏂扮殑UIWindow涓)

錛2錛塠UIApplication sharedApplication].keyWindow錛堣幏鍙栧簲鐢ㄧ▼搴忕殑涓葷獥鍙o級鐢ㄦ潵鎺ユ敹閿鐩樹互鍙婇潪瑙︽懜綾葷殑娑堟伅浜嬩歡鐨刄IWindow錛岃屼笖紼嬪簭涓姣忎釜鏃跺埢鍙鑳芥湁涓涓猆IWindow鏄痥eyWindow銆

鎻愮ず錛氬傛灉鏌愪釜UIWindow鍐呴儴鐨勬枃鏈妗嗕笉鑳借緭鍏ユ枃瀛楋紝鍙鑳芥槸鍥犱負榪欎釜UIWindow涓嶆槸keyWindow

錛3錛塿iew.window鑾峰緱鏌愪釜UIView鎵鍦ㄧ殑UIWindow

鍥涖佸洓澶у硅薄鐨勫叧緋誨浘

浜斻佷富紿楀彛鍜屾$獥鍙h存槑

浠g爜錛

// 紼嬪簭鍚鍔ㄥ畬姣曚箣鍚庡氨浼氳皟鐢ㄤ竴嬈
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// 1.鍒涘緩UIWindow
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// 璁劇疆UIWindow鐨勮儗鏅棰滆壊
self.window.backgroundColor = [UIColor redColor];

// 璁︰IWindow鏄劇ず鍑烘潵(璁╃獥鍙f垚涓轟富紿楀彛 騫朵笖鏄劇ず鍑烘潵)
// 涓涓搴旂敤紼嬪簭鍙鑳芥湁涓涓涓葷獥鍙
[self.window makeKeyAndVisible];
// 璁︰IWindow鎴愪負涓葷獥鍙
// [self.window makeKeyWindow];

// 2. 鍐嶅壋寤轟竴涓紿楀彛
UIWindow *w2 = [[UIWindow alloc] initWithFrame:CGRectMake(100, 100, 200, 200)];
w2.backgroundColor = [UIColor yellowColor];
[w2 makeKeyAndVisible];
self.w2 = w2;

// 3.鍒涘緩涓や釜鏂囨湰杈撳叆妗
// 3.1灝嗘枃鏈杈撳叆妗嗘坊鍔犲埌window涓
UITextField *tx1 = [[UITextField alloc] initWithFrame:CGRectMake(10, 10, 200, 40)];
tx1.borderStyle = UITextBorderStyleRoundedRect;
[self.window addSubview:tx1];

// 3.2灝嗘枃鏈杈撳叆妗嗘坊鍔犲埌w2涓
UITextField *tx2 = [[UITextField alloc] initWithFrame:CGRectMake(10, 10, 100, 40)];
tx2.borderStyle = UITextBorderStyleRoundedRect;
[self.w2 addSubview:tx2];

// 鑾峰彇搴旂敤紼嬪簭鐨勪富紿楀彛
NSLog(@"%@", [UIApplication sharedApplication].keyWindow);
return YES;
}

浠g爜璇存槑錛

鍐嶅壋寤轟竴涓紿楀彛錛堜富紿楀彛鍜屾$獥鍙g殑鍖哄埆錛

灞閮ㄥ彉閲忥紝闇瑕佸畾涔変竴涓猈indow灞炴ф潵淇濆瓨鍙橀噺銆

window鐨勫睘鎬у畾涔変負strong錛屽氨鏄涓轟簡璁╁叾涓嶉攢姣併

涓涓搴旂敤紼嬪簭鍙鑳芥湁涓涓涓葷獥鍙o紝紼嬪簭涓鍒涘緩浜嗕袱涓猈indow錛岄偅涔堣皝鏄涓葷獥鍙o紵鍚庨潰鐨勭獥鍙h兘瑕嗙洊鍓嶉潰鐨勭獥鍙c

鎻愮ず錛氬傛灉UItextfield涓嶆樉紺猴紝鍙浠ヨ冭檻璁劇疆瀹冪殑鏍峰紡錛屽洜涓哄叾鍒涘緩榛樿ゆ槸鉶氱嚎鐨勶紝娌℃湁杈規嗐

鍦╥os7閲岃竟錛屼富紿楀彛鍜屾$獥鍙f槸娌℃湁鍖哄埆鐨

鍦╥os7浠ュ墠涓鏈夊尯鍒錛氬摢涓鏄涓葷獥鍙o紝鍚庨潰璁劇疆涓轟富紿楀彛浼氭妸涔嬪墠璁劇疆鐨勮嗙洊鎺夈傦紙鍙鏈変富紿楀彛鎵嶈兘鍝嶅簲閿鐩樼殑杈撳叆浜嬩歡錛屽傛灉涓嶈兘杈撳叆鍐呭癸紝鍙浠ユ煡鐪嬫槸鍚︽槸鏄劇ず鍦ㄤ富紿楀彛涓婏紝涓嶅湪涓葷獥鍙d笂鐨勪笉鑳藉搷搴斻傦級

鍏銆佽ˉ鍏呰存槑

鍦ㄦ湁storyboard涓鐨勫壋寤鴻繃紼嬶細

鍏堟墽琛孧ain鍑芥暟錛屾墽琛孶IApplicationMain錛堬級,鏍規嵁鍏剁涓変釜鍜岀
鍥涗釜鍙傛暟鍒涘緩Application錛屽壋寤轟唬鐞嗭紝騫朵笖鎶婁唬鐞嗚劇疆緇檃pplication錛屾牴鎹欏圭洰閰嶇疆鏂囦歡info.plist閲岄潰鐨
storyboard鐨刵ame錛屾壘鍒板瑰簲鐨剆toryboard錛屾帴涓嬫潵鍒涘緩涓涓獁indow錛屼箣鍚庡壋寤哄畠鐨勫垵濮嬪寲鎺у埗鍣錛堝氨鏄綆澶存墍鎸囧悜鐨勬帶鍒跺櫒錛夛紝
鑷鍔ㄦ妸璇ユ帶鍒跺櫒璁劇疆涓篣IWindow鐨勬牴鎺у埗鍣錛屾帴涓嬫潵鍐嶅皢window鏄劇ず鍑烘潵錛屽嵆鐪嬪埌浜嗚繍琛屽悗鏄劇ず鐨勭晫闈銆

娉ㄦ剰榪欎釜鎺у埗鍣ㄥ睘鎬ч潰鏉誇笂鐨勨滃垵濮嬪寲鎺у埗鍣ㄥ睘鎬р濄

鍦ㄦ病鏈塻toryboard涓鐨勫壋寤鴻繃紼嬶細

鍏堟墽琛孧ain鍑芥暟錛屾墽琛孶IApplicationMain錛堬級,鏍規嵁鍏剁涓変釜鍜岀
鍥涗釜鍙傛暟鍒涘緩Application錛屽壋寤轟唬鐞嗭紝騫朵笖鎶婁唬鐞嗚劇疆緇檃pplication錛屽紑鍚涓涓浜嬩歡寰鐜錛屽綋紼嬪簭鍔犺澆瀹屾瘯錛屼粬浼氳皟鐢ㄤ唬鐞嗙殑
didFinishLaunchingWithOptions:鏂規硶銆傚湪璇ユ柟娉曚腑錛屼細鍒涘緩涓涓猈indow,鐒跺悗鍒涘緩涓涓鎺у埗鍣錛屽苟鎶婅ユ帶鍒跺櫒璁劇疆涓
UIWindow鐨勬牴鎺у埗鍣錛屾帴涓嬫潵鍐嶅皢window鏄劇ず鍑烘潵錛屽嵆鐪嬪埌浜嗚繍琛屽悗鏄劇ず鐨勭晫闈銆

C. 鑳藉悓鏃剁敤浜 Android 鍜 iOS鐨凙PP UI璁捐℃庝箞鍋

銆閬靛驚榪欎簺姝ラわ紝浣犵殑 App 灝辮兘鍚屾椂鍦 iOS 鍜 Android 淇濇寔瀹岀編!
銆銆1. 鎬諱綋鐨勬牱寮
銆銆浠 iOS7 浠ュ悗錛孉pple 灝變竴鐩村湪閲囩敤鎵佸鉤鍖栫殑璁捐℃ā寮忥紝鍘婚櫎浜嗘墍鏈変笉蹇呰佺殑綰圭悊鍜岄槾褰辯瓑鏁堟灉鈥斺斿拰鏃╀簺騫撮棿鐨勭増鏈瀹屽叏涓嶅悓銆侴oogle 鐨勬柊 MD 璁捐¤勮寖鏈変簡涓浜涙洿鍔犵粏鑺傜殑瑙勫畾錛岄氳繃涓縐嶅彨鈥滅焊鐗団濈殑鏂規硶鏉ュ壋閫犳洿澶氱殑灞傜駭鍏崇郴銆
銆銆2. 瀹炰綋鎸夐挳
銆銆Android 鏈変竴涓榪斿洖鎸夐挳錛岀偣鍑誨畠鍙浠ヨ繑鍥炰笂涓涓灞忓箷銆
銆銆iPhone 涓婂垯娌℃湁榪欐牱涓涓鎸夐挳錛屾墍浠ラ渶瑕佹湁涓縐嶆柟寮忚兘澶熻╃敤鎴峰洖鍒板厛鍓嶇殑灞忓箷銆傞氬父鐨勮В鍐蟲柟妗堟槸鍦ㄥ睆騫曠殑宸︿笂瑙掓斁緗涓涓榪斿洖閿銆
銆銆3. 閫氱敤鍏冪礌
銆銆涓ょ嶅鉤鍙頒箣闂寸殑紜瀛樺湪鐫涓浜涢氱敤鐨勫厓緔狅紝姣斿傝寸姸鎬佹爮鍜屾爣棰樻爮錛屽畠浠浼氬嚭鐜板湪姣忎竴灞忕殑欏墮儴銆備綘涓嶅簲褰撴敼鍙樺艱埅鏍忕殑楂樺害錛屽傛灉浣犳兂璁 App 鐪嬭搗鏉ユ洿鍔犲師鐢熺殑璇濄傛墍浠ワ紝鎴戞帹鑽愪綘鍦ㄨ捐$殑絎涓欏靛氨瀹氫箟濂芥爣棰樻爮鐨勬牱寮忥紝鐒跺悗鍦ㄥ叾浠栫殑灞忓箷涓婁嬌鐢ㄤ竴涓鍗犱綅鐨勬柟妗嗘潵鏇誇唬錛岃繖鏍瘋兘鐪佷笅涓嶅皯鏃墮棿錛屼絾鏄浣犲簲褰撳悜紼嬪簭鍛樿存槑鏍囬樻爮鍦ㄤ笉鍚岀殑灞忓箷涓婇兘鏄涓鏍風殑鏍峰紡銆
銆銆涓嶅悓騫沖彴涓婄殑瀵艱埅鏍忔湁涓瀹氱殑宸鍒銆傚湪 Android 涓婃枃鏈鏄宸﹀歸綈鐨勶紝鐒惰 iOS 涓婃槸灞呬腑瀵歸綈鐨勩傚湪 iOS 涓婏紝寰堝氫紒涓氶兘鐢ㄥ畠浠鐨 logo 鏉ユ浛鎹㈤栭〉鏍囬樻爮涓鐨勬枃瀛楋紝浣嗘槸鍦 Android 璁懼囦笂榪欎笉鏄涓涓濂界殑涓繪剰銆傜姸鎬佹爮(鏄劇ず浣犵殑緗戠粶銆佺數閲忓拰鏃墮棿淇℃伅)鏄緋葷粺緇勪歡錛屼綘涓嶉渶瑕佽冭檻璁捐″畠錛屽彧瑕佺『淇濆畠浠涓嶄細瀵逛粬浜洪犳垚璇瑙e氨濂戒簡銆
銆銆4. 瀵艱埅
銆銆鎴栬竔OS 鍜 Android 騫沖彴涔嬮棿鏈澶х殑鍖哄埆灝卞湪浜庝粬浠鐨勫艱埅鏍峰紡浜嗐侫ndroid 涓婃渶涓昏佺殑瀵艱埅鏂瑰紡鏄鎶藉眽鑿滃崟錛孉ndroid 鐢ㄦ埛浠閫氬父鍦ㄨ繖涓鑿滃崟鍐呰繘琛岃煩杞銆傝屼笖鍦ㄦ暣涓 App 涓錛岃繖縐嶄綋楠屾槸涓璐鐨勩侫pple 鐨勫艱埅鏍峰紡鏇村懼悜浜 tab bar錛屽畠浣嶄簬灞忓箷鐨勫簳閮錛屽苟涓斾互涓縐嶅緢綆鍗曠殑鏂瑰紡瀹炵幇涓婇儴鍐呭圭殑鍒囨崲銆傚綋浣犺捐 App 鐨勭粨鏋勭殑鏃跺欙紝浣犲彲浠ヤ負涓嶅悓鐨勫鉤鍙拌捐′笉鍚岀殑瀵艱埅鏍峰紡銆
銆銆5. 瑕佷笉瑕佺敤鍗$墖寮
銆銆鍦 UI 璁捐′腑錛屽崱鐗囨i愭笎鎴愪負涓縐嶄富瑕佺殑 UI 璁捐℃牱寮忥紝瀹冧滑鍙浠ュ簲浠樺氱嶆儏鍐碉紝鑰屼笖緇欑敤鎴鋒彁渚涗簡涓縐嶈兘澶熷憟鐜版湁鏁堝唴瀹圭殑渚挎嵎鏂瑰紡銆傝嗚変笂錛屽崱鐗囬潪甯擱傚簲浜 Android 鐨 Material Design(瀹冧簨瀹炰笂婧愯嚜浜庣焊寮犵殑鐏墊劅)銆備嬌鐢ㄩ槾褰卞拰鍗$墖涔嬮棿鐨勫悎鐞嗛棿璺濊兘澶熷壋寤轟竴縐嶈嚜鐒剁殑澶栬傘
銆銆鍦 iOS 涓婏紝浣跨敤鍗$墖璁捐¢渶瑕佹洿鍔犵殑灝忓績璋ㄦ厧錛屽敖綆′竴浜涘ぇ鍨嬬殑 App錛岃稿 Facebook 鍜 pinterest 鐨勭『浣跨敤浜嗕竴縐嶇暐寰鍋忕 iOS 瑙嗚夎勮寖鐨勮捐¢庢牸銆侷nstagram 浣跨敤浜嗕竴縐嶅畬鍏ㄦ墎騫沖寲鐨勮捐¢庢牸錛屽敖綆′粠緇撴瀯鐨勮傜偣涓婄湅錛岀敤鎴風殑姣忎竴鏉℃帹閫侀兘鑳借瑙嗕負鏄涓寮犲崱鐗囷紝instagram 鐨勮捐″緢鍊煎緱浣犲幓鑺辨椂闂存彛鎽╋紝瀹冩槸濡備綍閬靛驚 iOS 瑙嗚夎勮寖鐨勩傚傛灉浣犺佸湪 iOS 騫沖彴涓婂簲鐢ㄩ槾褰憋紝浣犳渶濂藉皬蹇冭皚鎱庯紝灝介噺浣垮緱榪欎簺闃村獎涓嶆槸閭d箞鐨勬槑鏄俱
銆銆6. 鎺掔増
銆銆iOS 緋葷粺涓婄殑榛樿ゅ瓧浣撴槸 Helvetica Neue錛屽湪 Android 涓婂垯鏄 Roboto銆傚敖綆¤繖涓ょ嶅瓧浣撳湪澶栬備笂鏈夋樉钁楃殑宸寮傦紝浣嗘槸榪欎袱涓瀛椾綋鐨勫昂瀵稿嵈鏄榪戜箮鐩稿悓鐨勩傚傛灉浣犳兂瑕佸湪璁捐$殑鏃跺欒妭鐪佹椂闂達紝閭d箞鐢ㄤ竴嬈懼瓧浣撳氨鍙浠ワ紝浣嗘槸瑕佸拰寮鍙戜漢鍛樻矡閫氬湪涓嶅悓鐨勫鉤鍙頒笂浣跨敤瀵瑰簲鐨勫瓧浣撱傝屽湪璁捐¢噸瑕佺殑甯冨矓緇撴瀯鍜屼嬌鐢ㄥぇ鍙峰瓧浣撴椂錛屾垜寤鴻浣犺繕鏄鍚屾椂鐢ㄨ繖涓ょ嶅瓧浣撴祴璇曟晥鏋溿
銆銆濡傛灉浣犳兂瑕佺簿鐩婃眰綺撅紝閭d箞浣犲氨瑕佸逛笉鍚屽鉤鍙頒笂鐨勮捐¤勮寖鏇村姞娉ㄦ剰銆傛瘮濡傚備笅鍑犳潯錛
銆銆Android 鐨 MD 璁捐¢渶瑕佺敤鍒版洿澶氱殑絀烘牸鏉ヨ繘琛屽竷灞
銆銆鍦 MD 涓瀛椾綋澶у皬鐨勫彉鍖栦細鏇村姞澶氭牱
銆銆鍦 iOS 涓婏紝瀛椾綋娌¢偅涔堝氬ぇ灝忓樊寮傦紝浣嗘槸鍦ㄥ瓧浣撻噸閲忎笂(Font weight)鏈夋洿澶氱殑鍙樺寲錛屽悓鏍峰厑璁鎬綘鍒涘緩涓繪$粨鏋
銆銆涓や釜騫沖彴閮戒嬌鐢ㄦ瘮杈冪粏鐨勫瓧浣撴潵鐜板疄姝f枃鍐呭癸紝鐒惰岋紝鍦ㄤ笅闈㈢殑渚嬪瓙涓錛孉ndroid 浣跨敤浜嗚交(Lighr)鍜屽父瑙(Regular)瀛椾綋錛岃 iOS 浣跨敤浜嗙矖浣(Bold)鍜屽父瑙勫瓧浣
銆銆榪欐槸涓涓闈炲父綆鍗曠殑渚嬪瓙錛屽悜浣犲睍紺轟簡鎺掔増鏂歸潰鐨勪竴浜涚粏寰鐨勪笉鍚屽彲浠ュ艱嚧鍗拌薄涓婄殑宸ㄥぇ宸寮傗斺斾綘鑳藉緢蹇鍒嗚鯨浣犳槸鍦ㄧ敤 Android 鎵嬫満榪樻槸鍦ㄧ敤 iPhone!
銆銆7. 緗戞牸鍜岃Е鎽稿厓浠
銆銆iOS(@1x 涓 44px)鍜 Android(1:1 姣旂巼涓 48p)閮芥湁瀵瑰彲瑙︽懜鍏冧歡鐨勮捐¤勮寖銆侻D 瑙勮寖鍚屾牱寤鴻瀵規墍鏈夊厓緔犱嬌鐢 8dp 緗戞牸瀵歸綈銆
銆銆鍦ㄦ渶榪戠殑欏圭洰涓婏紝鎴戝彂鐜伴伒瀹 Android 鐨勮繖浜涜捐¤勮寖浼氭洿鍔犲畨鍏錛屽洜涓哄ぇ涓浜涚殑 48px 鐨勬寜閽鍦ㄤ袱涓騫沖彴涓婇兘琛ㄧ幇鑹濂斤紝鑰屼笖 MD 鐨勮勮寖鏇村姞鍏ㄩ潰錛岃繕緇忓父鏇存柊銆備笉綆℃庝箞璇達紝浣犻兘搴旇ュ湪璁捐′腑浣跨敤緗戞牸錛屼絾鏄鎴戜滑鍙戠幇瀹氫箟鏇村姞鏄庣『鐨 Android 緗戞牸浼氭洿濂界敤涓浜涖

閱讀全文

與iosui編程相關的資料

熱點內容
壓縮干糧圖片 瀏覽:838
怎麼看網站被加密的視頻 瀏覽:848
哪個app可以弄會動的照片模板 瀏覽:272
如何關閉電腦的時鍾源伺服器 瀏覽:902
adb命令設置主屏幕應用 瀏覽:990
編譯後的bak文件 瀏覽:259
php生成文件名 瀏覽:880
日照智能車輛移動機器人導航演算法 瀏覽:115
解壓力的食療 瀏覽:125
密鑰如何加密隨機數 瀏覽:381
統計學中pre的演算法 瀏覽:411
inline函數在編譯時不做類型檢查 瀏覽:268
經緯度查詢android 瀏覽:762
vivoz5x方舟怎麼進伺服器 瀏覽:498
vivox50安卓微信人臉支付怎麼開啟 瀏覽:895
cmd退出python命令 瀏覽:534
恢復u盤加密隱藏的文件 瀏覽:925
對某個人加密應該用公鑰 瀏覽:1002
機頂盒中央1加密 瀏覽:98
單片機的出現有什麼影響 瀏覽:232