导航:首页 > 编程语言 > 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编程相关的资料

热点内容
解压力的食疗 浏览:121
密钥如何加密随机数 浏览:379
统计学中pre的算法 浏览:409
inline函数在编译时不做类型检查 浏览:266
经纬度查询android 浏览:760
vivoz5x方舟怎么进服务器 浏览:496
vivox50安卓微信人脸支付怎么开启 浏览:893
cmd退出python命令 浏览:531
恢复u盘加密隐藏的文件 浏览:921
对某个人加密应该用公钥 浏览:998
机顶盒中央1加密 浏览:95
单片机的出现有什么影响 浏览:227
linuxtar备份系统 浏览:63
窗口鼠标录制编译 浏览:84
云服务器可以攻击吗 浏览:558
主力吸筹派发区域指标源码 浏览:695
单片机pc的低字节怎么算 浏览:230
pythoneval函数源码 浏览:242
linuxmongodb服务启动 浏览:766
在哪里下载核酸检测app 浏览:310