728x90 ๋ฐ์ํ ๐ iOS/UI59 [iOS/UI] ํญ๋ฐ ๊ธธ์ด ์กฐ์ ๋ฐ ์์ดํ ์์น ๋ฐฐ์ด(UITabBar height & UITabBar item image insets) ์๋์ด๋ฏธ์ง๋ฅผ ๋ณด๋ฉด ๋ด ๊ธฐ์ค์์ ํญ๋ฐ ์์ดํ ๋ค์ด ์ด์ง ์๋ก ๊ฐ์๋ค. ๊ทธ๋์ ๋ด๋ฆด ์ ์๋ ๋ฐฉ๋ฒ์ ์ฐพ๋ค๊ฐ ์ ํ๋ฌธ์์์ ์๋ ํ๋กํผํฐ๋ฅผ ๋ฐ๊ฒฌํ๋ค. ์ด๋ฏธ์ง ์ธ์ ์ด๋ผ๋ ๊ฑด๋ฐ ๊ฐ ๊ผญ์ง์ ๋ค์ ์ง์ ํด ์์น๋ฅผ ์ฌ๋ฐฐ์ดํ ์ ์์๋ค. ์ฐ์ ์คํ ๋ฆฌ๋ณด๋์ ๋ทฐ์ปจํธ๋กค๋ฌ์ ํญ๋ฐ์์ดํ ์์น๊ฐ ์๋ ๋ถ๋ถ์ ํด๋ฆญํ๊ณ ์ธ์คํํฐ๋ฅผ ์ด๋ฉด 6๋ฒ์งธ size ์ธ์คํํฐ์ image inset์ด ์๋ค. ๋ชจ๋ 0์ผ๋ก ์ค์ ๋์ด ์๋ค. ๋ ์์ดํ ๋ค์ ๋ด๋ ค์ผํ๊ธฐ ๋๋ฌธ์ ๋ฐํ ์ -20๊ฐ์ ์ค๋ณด์๋ค. ๊ทธ๋ฌ๋๋ ์ ์๋ณด์ผ์๋ ์์ง๋ง ์๋๋ก ์ฝ๊ฐ ์ด๋ํ ๊ฒ์ ๋ณผ ์ ์๋ค! ๊ทธ๋ฆฌ๊ณ ๋ ์์ดํ ์ ๋ด๋ฆฌ๊ธฐ๋ณด๋จ ํญ๋ฐ ๋์ด๋ฅผ ์ค์ด๋ฉด ๋์ง ์์๊น? ๋ผ๋ ์๊ฐ์ ํญ๋ฐ ํค์ดํธ๋ฅผ ์กฐ์ ํ๋ ํจ์๋ฅผ ์ฐพ์๋ณธ ๊ฒฐ๊ณผ ์๋ ์ฝ๋๋ฅผ ์ฐพ๊ฒ ๋์๊ณ ์ฝ๊ฒ ์ํ๋ ๊ธธ์ด๋ฅผ ์ง์ ํ๋ฉด ๋ฐ๊ฟ ์ ์์๋ค. ex.. 2019. 12. 29. [iOS/UI] UICollectionView ์คํฌ๋กคํ๋ฉด ์์น๋ฐ ์จ๊ธฐ๊ธฐ ์ฝ๋ ์ ๋ทฐ๋ฅผ ์คํฌ๋กคํ๋ ๋ฒ์ ์์๋ด๋ ๊ฑด scrollViewDidScroll์ด๋ผ๋ ๋ฉ์๋๋ฅผ ์ฐ๋ฉด ์ ์ ์๋ค. //์ฝ๋ ์ ๋ทฐ์ ํ์ํด๋์ค๊ฐ ์คํฌ๋กค๋ทฐ์ด๊ธฐ ๋๋ฌธ์ ์ฝ๋ ์ ๋ทฐ ๋๋ฆฌ๊ฒ์ดํธ๊ฐ ์๋ค๋ฉด ์ด์ ๊ฐ์ ํจ์๋ฅผ ์ธ ์ ์๋ค. func scrollViewDidScroll(_ scrollView: UIScrollView) { let actualPosition = scrollView.panGestureRecognizer.translation(in: scrollView.superview) //์คํฌ๋กค ์๋์ธ์ง ์์ธ์ง ์์๋ด๋ ํฌ์ง์ if (actualPosition.y > 0){ // ์๋๋ก ๋ด๋ฆฐ ๊ฒ searchheight.constant = 38 //searchbarheight๋ฅผ 38๋ก ๋ฐ๊ฟ UIView.animate(.. 2019. 12. 26. [iOS/UI]UICollectionView header๋ง๋ค๊ธฐ(UICollectionReusableView) ์คํ ๋ฆฌ๋ณด๋์์ ํด๋น ์ฝ๋ ์ ๋ทฐ์ CollectionReusableView๋ฅผ ์ถ๊ฐํด์ค ๋ค UICollectionReusableView ํ์ผ์ ๋ฐ๋ก ๋ง๋ค์ด์ค๋ค. CollectionReusableView ํด๋์ค์ ์์ฑํด์ค ํ์ผ ์ด๋ฆ์ ์ ๊ณ identifier์ ์ด๋ฆ์ ๋ฐ๋ก ์์ฑํด์ค๋ค. ๊ทธ๋ฆฌ๊ณ ์ฝ๋ ์ ๋ทฐ๊ฐ ์๋ ํด๋์ค์ ์๋ ๋ฉ์๋๋ฅผ ์ถ๊ฐํด์ฃผ๋ฉด ๋! func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { //ofKind์ UICollectionView.elementKindSectionHea.. 2019. 12. 26. [iOS/UI] UIButton ์์๋ง ๋ฅ๊ธ๊ฒ ํ๊ธฐ //์ต์คํ ์ ์ ์ค์ ํด์ฃผ๊ณ extension UIButton { func roundedButton(){ clipsToBounds = true //๋ทฐ์ ํ ๋๋ฆฌ ๊ธฐ์ค์ผ๋ก ์งค๋ฆฌ๊ฒ ๋๋ค. layer.cornerRadius = 10 //์ผ๋งํผ ๋ฅ๊ธ๊ฒ layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner] //์ ์ผ ์ผ์ชฝ์์์ ์ ์ผ ์ค๋ฅธ์ชฝ ์๊น์ง ๋ฅ๊ธ๊ฒ // ์๋๋ ๋ฒํผ์ ๋ณด๋๋ฅผ ์ ํด์ฃผ๋๊ฒ // layer.borderWidth = 1 // layer.borderColor = UIColor(displayP3Red: 211/255, green: 211/255, blue: 211/255, alpha: 1).cgColor } } override func view.. 2019. 12. 26. [iOS/UI] UITableView ์์ฒด Height ์ค์ ํ๊ธฐ (NSLayoutConstraint) TableView์ Rowํ ๋ง๊ณ ๊ทธ ์์ฒด์ ๋์ด๋ฅผ ์ ํด์ผ ํ ๋๊ฐ ์๋ค. ๊ทธ๋์ ์ฐพ์๋ณธ ๊ฒฐ๊ณผ TableView Height๋ฅผ ๋ฐ๊พธ๋ ค๋ฉด Storyboard์์ height๋ฅผ ์ค์ ํด์ฃผ๊ณ ๊ทธ NSLayoutConstraint์ ํด๋น ๋ทฐ์ ์ฐ๊ฒฐํด์ฃผ๊ณ ๊ทธ ์์๋ ์์ .constant = ์ํ๋ ๊ฐ์ ํด์ฃผ๋ฉด ์ค์ ๋๋ค. 2019. 12. 12. [iOS] CollectionViewCell ์ข์ธก์ผ๋ก ์ ๋ ฟ๋ผ๊ธฐ ์ฝ๋ ์ ๋ทฐ์์ item๊ฐ minspacing์ ์ ํด์ฃผ์ด๋ ์ ํฌ๊ธฐ์ ๋ฐ๋ผ ์คํ์ด์ฑ์ด ๋ฌ๋ผ์ก๋ค. ๊ตฌ๊ธ์ ๊ฒ์ํด๋ณธ ๊ฒฐ๊ณผ ์ฝ๋ ์ ๋ทฐ๋ฅผ ์ข์ธก์ ๋ฐฐ์ดํด์ผํ๋ค๋ ์ฌ์ค์ ์์๋ค. ๊ทธ๋์ ์์ฃผ ์ข์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ธ DGCollectionViewLeftAlignFlowLayout๋ฅผ ์ฐพ์๋ค. ์์ฃผ ๊ฐ๋จํ๊ณ ์ฌ์ฉํ๊ธฐ ์ฌ์ ๋ค. pod 'DGCollectionViewLeftAlignFlowLayout' //ํํ์ผ์ ์ถ๊ฐ import DGCollectionViewLeftAlignFlowLayout //์ํฌํธ ํด๋นํด๋์ค์ UICollectionViewDelegateFlowLayout๋๋ฆฌ๊ฒ์ดํธ๋ฅผ ์ถ๊ฐํด์ค๋ค. override func viewdidload()๋ override func awakeFromNib()// ์ด๊ณณ์ ์๋ ์ถ๊ฐ colle.. 2019. 12. 11. [iOS/UI] Readmore ๊ตฌํํ๊ธฐ ์ด๋ ๊ฒ ๋ณ์๋ค์ ์ ์ธํด๋๊ณ class Main: UITableViewController { var headerheight = 215 var headerheights = [Int : Int]() var moreless = "more" var moreindex = 100 var morearray = [Int]() ์ฐ์ ์ ์์ ๋ฒํผ์ addTarget ํด์ค๋ค. action์์๋ ์ค์ ํด๋์ ํจ์๋ฅผ ์ง์ด๋ฃ๋๋ค. cell.morebtn.addTarget(self, action:#selector(Main.more(sender:)) , for: UIControl.Event.touchUpInside) ์ค์ ํด๋์ more์ด๋ผ๋ ํจ์ ์์ ๋์ด๋ฅผ ์์๋ด๋ ํจ์ heightForView๋ฅผ ์ด์ฉํด ๊ธธ์ด๋ฅผ ์์๋ด๊ณ sender.. 2019. 12. 11. [iOS/UI] UIAlertController ๊ธ์จ์๋ฐ๊พธ๊ธฐ let alertController = UIAlertController(title: "", message: "", preferredStyle: .alert) let cancelAction = UIAlertAction(title: "Cancel", style: .cancel) { (action) in // Cancel๋ฒํผ ๋๋ ์ ๋ ๋ญํ ๊ฑฐ์ผ } alertController.addAction(cancelAction) let OKAction = UIAlertAction(title: "OK", style: .default) { (action) in } OKAction.setValue(UIColor(displayP3Red: 162/255, green: 32/255, blue: 58/255, alpha: 1), f.. 2019. 12. 11. [iOS/UI] UILabel ํน์ ๋ถ๋ถ์ ๋ฐ์ค ๊ธ๊ธฐ wholeStr์ ์ํ๋ ์ ์ฒดํ ์คํธ๋ฅผ ์จ์ฃผ๊ณ ๊ทธ๋ฆฌ๊ณ rangeToUnderLine์ wholeStr์ค ๋ฐ์ค์ ์ํ๋ ๋ถ๋ถ์ ์ ์๋ค๋ค (range(of:) ์ด๊ณณ์) let rangeToUnderLine = NSRange(location: 0, length: 10)) 2019. 12. 4. [iOS/UI] UITabbar ๊ฐ์ด๋ฐ์ ๋ฒํผ ๋ฃ๊ธฐ ํญ๋ฐ๋ฅผ ์ด์ฉํ๋ค๋ณด๋ฉด ๊ฐ์ด๋ฐ๋ ํน์ ๋ค๋ฅธ ๊ณณ์ ๋ฒํผ์ฒ๋ผ ๋๊ณ ์ถ์ ๋๊ฐ ์์ต๋๋ค. ํ์ง๋ง ํญ๋ฐ๋ ๋๋ ์ ๋๋ง ๊ทธ ์์ ์์์ ๋ณ๊ฒฝํ ์ ์์ด์ ๋ฒํผ์ ๋ฐ๋ก ์ถ๊ฐํด์ค์ผํ๋๋ฐ์ ์ด๊ฒ์ ํ ์ ์๋ ๋ฐฉ๋ฒ์ ์๊ฐํด๋๋ฆฌ๊ฒ ์ต๋๋ค! ์ฒซ๋ฒ์งธ๋ก UITabbarController๋ฅผ ํ์ฑํด์ค๋๋ค. ๊ทธ๋ฆฌ๊ณ setupMiddleButton์ด๋ผ๋ ํจ์๋ฅผ ๋ง๋ค์ด ๊ทธ ์์ menuButton์ ํ๋ ๋ง๋ค์ด์ค๋๋ค. ๊ทธ ๋ค ๋ฐฐ๊ฒฝ์์(backgroundColor) ์ ํ๊ณ ์ํ๋ ์ด๋ฏธ์ง(setImage)๋ฅผ ๋ฃ์ด์ค๋๋ค. ์ด๋ฏธ์ง๋ฅผ ์ด๋ค ํ์์ผ๋ก ์ฑ์๋ฃ์ ๊ฒ์ธ์ง๋ ์ค์ ํด์ค๋๋ค.(contentMode) ๊ทธ๋ฆฌ๊ณ ๋ฒํผ์ ๋๋ฅผ ์ ์๊ฒ addTarget์ ์ค์ ํด์ฃผ๊ณ ์ ๋ ํฐ ์์ menuButtonActionํจ์๋ฅผ ๋ฃ์ด์ค๋๋ค. ๊ทธ ๋ค์ ์ฝ๋๋ ํด๋ํฐ๋ง๋ค ํ.. 2019. 11. 26. [iOS] ํ๋ฉด์ ํ์ ํ์คํฌ๋ฆฐ์ผ๋ก ๋ง๋ค๊ธฐ (modaPresentaionStyle FullScreen) ํ๋ฉด ์ด๋์ ํ ๋ ํ๋ฉด์ด ์์ด๋ฉด์ ํ๋ฉด์ด ์ฝ๊ฐ ์๋๋ก ๊ฐ๋ ํ์์ ๊ฒช๊ฒ ๋์๋ค. ๋๋ ํ๋ฉด์ ๊ฝ ์ฑ์ฐ๊ณ ์ถ์๋ฐ ์ด๋ป๊ฒ ํด์ผํ์ง ํ๋ฉฐ ๊ตฌ๊ธ๋ง์ ํ๋ค๊ฐ ํด๋ต์ ์ฐพ์๋๋ฐ 2๊ฐ์ง๊ฐ ์๋ค. ์ฒซ๋ฒ์งธ๋ ํด๋น ๋ทฐ์ปจ๋๋กค๋ฌ์ Presentaion์ Full Screen์ผ๋ก ๋ฐ๊ฟ์ฃผ๋ ๊ฒ์ด๋ค.(์๋๋ Automatic์ด๋ผ ๋์ด์๋๋ฐ ์คํ ๋งคํฑ์ผ๋ก ๋์ด์์ผ๋ฉด ์ ์ ํ๋ฉด์ฒ๋ผ ๋์ค๊ฒ ๋๋ค.) ์ฝ๋๋ก ํ๋ฉด์ ์ด๋ํ ๋๋ ์ modaPresentaionStyle์ .fullScreen์ผ๋ก ํด์ฃผ๋ฉด ๋๋ค. ์ฝ๋๋ ์คํ ๋ฆฌ๋ณด๋์์ ๋ฐ๊พผ ๊ฒฐ๊ณผ ํ๋ฉด์ด ๊ฝ ์ฐจ๊ฒ ๋์๋ค. 2019. 11. 25. ์ด์ 1 2 3 4 5 ๋ค์ 728x90 ๋ฐ์ํ