[study#6-3] 程式手刻emoji 表情符號& logo-有隻黑貓

文章推薦指數: 80 %
投票人數:10人

學習clipsToBounds 的效果. “[study#6-3] 程式手刻emoji 表情符號& logo-有隻黑貓” is published by Yolanda H. in 彼得潘的Swift iOS App 開發教室. 學生心得學習資源iOSApp課程[study#6-3]程式手刻emoji表情符號&logo-有隻黑貓YolandaH.FollowDec20,2018·10minread學習clipsToBounds的效果在網路上看中了卡通黑貓的造型,臉跟眼睛都可以練習用cornerRadius&clipsToBounds來做出。

眼睛形狀:用一個2比1的長方形,layer.cornerRadius數值高度相同,就可以做出一個橫的鳳眼形letwhiteView=UIView(frame:CGRect(x:30,y:40,width:80,height:40))whiteView.backgroundColor=UIColor.whitewhiteView.layer.cornerRadius=40whiteView.clipsToBounds=true瞳孔形狀:leteyeleftView=UIView(frame:CGRect(x:25,y:0,width:30,height:40))eyeleftView.backgroundColor=UIColor(red:0,green:0.2,blue:0,alpha:1)eyeleftView.layer.cornerRadius=20eyeleftView.clipsToBounds=true瞳孔外框:eyeleftView.layer.borderColor=UIColor(displayP3Red:0.1,green:0.6,blue:0.3,alpha:1).cgColoreyeleftView.layer.borderWidth=5由於並不是模仿哪個圖案一模一樣,一直在調整看怎樣好看點,莫名的就自己玩起來了……這是正常的黑貓這是生氣的黑貓這是芬蘭的黑貓甚至做起眼球運動了...(感覺這應該是另個app作業才對...)練習半圓形的微笑曲線:letelseView=UIView(frame:CGRect(x:0,y:-20,width:40,height:40))elseView.layer.borderColor=UIColor.orange.cgColorelseView.layer.borderWidth=5elseView.layer.cornerRadius=20elseView.clipsToBounds=trueletelse2View=UIView(frame:CGRect(x:35,y:-20,width:40,height:40))else2View.layer.borderColor=UIColor.orange.cgColorelse2View.layer.borderWidth=5else2View.layer.cornerRadius=20else2View.clipsToBounds=trueletnoseView=UIView(frame:CGRect(x:90,y:90,width:80,height:40))noseView.backgroundColor=UIColor.blacknoseView.clipsToBounds=truenoseView.addSubview(elseView)noseView.addSubview(else2View)faceView.addSubview(noseView).(覺得不笑好像比較像貓......)程式:importUIKitletblankView=UIView(frame:CGRect(x:0,y:0,width:350,height:350))letfaceView=UIView(frame:CGRect(x:50,y:100,width:250,height:160))faceView.backgroundColor=UIColor(red:0,green:0,blue:0,alpha:1)faceView.layer.cornerRadius=90faceView.clipsToBounds=trueblankView.addSubview(faceView)letearleftView=UIView(frame:CGRect(x:0,y:0,width:300,height:400))earleftView.backgroundColor=UIColor.blackletearleftPath=UIBezierPath()earleftPath.move(to:CGPoint(x:90,y:50))earleftPath.addLine(to:CGPoint(x:80,y:150))earleftPath.addLine(to:CGPoint(x:140,y:110))earleftPath.close()letearleftShape=CAShapeLayer()earleftShape.path=earleftPath.cgPathearleftView.layer.mask=earleftShapeletearrightView=UIView(frame:CGRect(x:0,y:0,width:300,height:400))earrightView.backgroundColor=UIColor.blackletearrightPath=UIBezierPath()earrightPath.move(to:CGPoint(x:260,y:50))earrightPath.addLine(to:CGPoint(x:270,y:150))earrightPath.addLine(to:CGPoint(x:210,y:110))earrightPath.close()letearrightShape=CAShapeLayer()earrightShape.path=earrightPath.cgPathearrightView.layer.mask=earrightShapeletwhiteView=UIView(frame:CGRect(x:30,y:40,width:80,height:40))whiteView.backgroundColor=UIColor.whitewhiteView.layer.cornerRadius=40whiteView.clipsToBounds=trueletwhite2View=UIView(frame:CGRect(x:140,y:40,width:80,height:40))white2View.backgroundColor=UIColor.whitewhite2View.layer.cornerRadius=40white2View.clipsToBounds=trueleteyeleftView=UIView(frame:CGRect(x:25,y:0,width:30,height:40))eyeleftView.backgroundColor=UIColor(red:0,green:0.2,blue:0,alpha:1)eyeleftView.layer.borderColor=UIColor(displayP3Red:0.1,green:0.6,blue:0.3,alpha:1).cgColoreyeleftView.layer.borderWidth=5eyeleftView.layer.cornerRadius=20eyeleftView.clipsToBounds=trueleteyerightView=UIView(frame:CGRect(x:25,y:0,width:30,height:40))eyerightView.backgroundColor=UIColor(red:0,green:0.2,blue:0,alpha:1)eyerightView.layer.borderColor=UIColor(displayP3Red:0.1,green:0.6,blue:0.3,alpha:1).cgColoreyerightView.layer.borderWidth=5eyerightView.layer.cornerRadius=20eyerightView.clipsToBounds=trueletelseView=UIView(frame:CGRect(x:110,y:80,width:30,height:10))elseView.layer.borderColor=UIColor.orange.cgColorelseView.layer.borderWidth=5elseView.layer.cornerRadius=20elseView.clipsToBounds=trueblankView.addSubview(earrightView)blankView.addSubview(earleftView)whiteView.addSubview(eyeleftView)white2View.addSubview(eyerightView)faceView.addSubview(whiteView)faceView.addSubview(white2View)faceView.addSubview(elseView)blankView.addSubview(faceView)彼得潘的SwiftiOSApp開發教室學習SwiftiOSApp開發的學生作品集140Clipstobounds140 claps140彼得潘的SwiftiOSApp開發教室學習SwiftiOSApp開發的學生作品集WrittenbyYolandaH.Follow悠琅妲之愛鷗恩思推敲推敲潑墨坊{iOSApp|websiteSEO|SAS|Aroma|Zumba|ChinesePoems|Tabletopgame}彼得潘的SwiftiOSApp開發教室學習SwiftiOSApp開發的學生作品集



請為這篇文章評分?