Skip to content

Commit

Permalink
カバー画像の説明追加
Browse files Browse the repository at this point in the history
  • Loading branch information
anzfactory committed Jul 3, 2015
1 parent a73c450 commit a12c5be
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
16 changes: 13 additions & 3 deletions QiitaCollection/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -1297,7 +1297,7 @@
</connections>
</segmentedControl>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="BAF-BE-4iA" userLabel="Picker">
<rect key="frame" x="138" y="66" width="44" height="44"/>
<rect key="frame" x="268" y="66" width="44" height="44"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="Qcf-qp-20a"/>
<constraint firstAttribute="width" constant="44" id="nd7-Um-xle"/>
Expand All @@ -1309,22 +1309,31 @@
<action selector="tapMedia:" destination="Uw2-GG-yMA" eventType="touchUpInside" id="ymG-Ou-bOl"/>
</connections>
</button>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" userInteractionEnabled="NO" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" editable="NO" text="投稿したユーザーのプロフィール画像が Grid Cover として表示されるようになります" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Y8m-HY-6GP">
<rect key="frame" x="8" y="61" width="252" height="61"/>
<fontDescription key="fontDescription" type="system" pointSize="11"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
</textView>
</subviews>
<color key="backgroundColor" red="0.40000000596046448" green="1" blue="0.80000001192092896" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="BAF-BE-4iA" firstAttribute="top" secondItem="KFE-33-KO4" secondAttribute="bottom" constant="18" id="2GO-Jq-K2f"/>
<constraint firstItem="KFE-33-KO4" firstAttribute="top" secondItem="Trm-Gu-R1x" secondAttribute="top" constant="20" id="7Tm-mk-eqk"/>
<constraint firstItem="Y8m-HY-6GP" firstAttribute="top" secondItem="KFE-33-KO4" secondAttribute="bottom" constant="13" id="Ufy-z3-LHH"/>
<constraint firstAttribute="trailing" secondItem="KFE-33-KO4" secondAttribute="trailing" constant="8" id="c4X-zy-99r"/>
<constraint firstAttribute="centerX" secondItem="BAF-BE-4iA" secondAttribute="centerX" id="hA2-b6-OCZ"/>
<constraint firstItem="BAF-BE-4iA" firstAttribute="trailing" secondItem="KFE-33-KO4" secondAttribute="trailing" id="cbW-Gc-jJF"/>
<constraint firstAttribute="bottom" secondItem="Y8m-HY-6GP" secondAttribute="bottom" constant="8" id="e96-M8-eDG"/>
<constraint firstItem="BAF-BE-4iA" firstAttribute="leading" secondItem="Y8m-HY-6GP" secondAttribute="trailing" constant="8" id="hNb-l6-woq"/>
<constraint firstItem="KFE-33-KO4" firstAttribute="leading" secondItem="Trm-Gu-R1x" secondAttribute="leading" constant="8" id="shh-8i-aUb"/>
<constraint firstAttribute="height" constant="130" id="uHA-LF-rRX"/>
<constraint firstItem="Y8m-HY-6GP" firstAttribute="leading" secondItem="Trm-Gu-R1x" secondAttribute="leading" constant="8" id="xje-0z-0Y9"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ovE-lF-lcV" userLabel="Image Panel">
<rect key="frame" x="0.0" y="64" width="320" height="374"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="設定されていません" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4Iq-98-dij">
<rect key="frame" x="83.5" y="177" width="153" height="20.5"/>
<rect key="frame" x="83" y="177" width="153" height="20.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
Expand Down Expand Up @@ -1377,6 +1386,7 @@
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/>
<connections>
<outlet property="controlPanel" destination="Trm-Gu-R1x" id="WMe-da-mK9"/>
<outlet property="coverDescription" destination="Y8m-HY-6GP" id="0fV-tZ-CiR"/>
<outlet property="coverImage" destination="pIi-D4-9GR" id="8Ci-Lh-GPX"/>
<outlet property="navigationBar" destination="Nbi-hO-e1Q" id="uwp-15-c9W"/>
<outlet property="picker" destination="BAF-BE-4iA" id="CUW-ym-RTU"/>
Expand Down
18 changes: 10 additions & 8 deletions QiitaCollection/ImageSettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ImageSettingsViewController: BaseViewController, UIImagePickerControllerDe
@IBOutlet weak var segmentCoverType: UISegmentedControl!
@IBOutlet weak var picker: UIButton!
@IBOutlet weak var coverImage: UIImageView!
@IBOutlet weak var coverDescription: UITextView!

override func viewDidLoad() {
super.viewDidLoad()
Expand Down Expand Up @@ -58,34 +59,35 @@ class ImageSettingsViewController: BaseViewController, UIImagePickerControllerDe
}

@IBAction func changeCoverType(sender: AnyObject) {
self.picker.hidden = self.segmentCoverType.selectedSegmentIndex == 2
switch self.segmentCoverType.selectedSegmentIndex {
case 0:
self.coverDescription.text = "設定された画像を View Cover(画面を覆う様に)として表示します"
case 1:
self.coverDescription.text = "設定された画像を Grid Cover(グリッドの1つ1つの背景)として表示します"
case 2: fallthrough
default:
self.coverDescription.text = "記事投稿者のプロフィール画像を Grid Cover として表示します(デフォルトはコチラ)"
}
}

func setupCoverImage() {
var index = 2
var image: UIImage? = nil
var hidden = false
if UserDataManager.sharedInstance.hasImageForGridCover() {
image = UserDataManager.sharedInstance.imageForGridCover()
index = 0
} else if UserDataManager.sharedInstance.hasImageForViewCover() {
image = UserDataManager.sharedInstance.imageForViewCover()
index = 1
} else {
hidden = true
self.coverImage.hidden = true
}
self.segmentCoverType.selectedSegmentIndex = index
self.coverImage.image = image
self.picker.hidden = hidden
}

func openImagePicker() {

if self.segmentCoverType.selectedSegmentIndex > 1 {
return
}

if (UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.PhotoLibrary)) {
let picker = UIImagePickerController()
picker.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
Expand Down

0 comments on commit a12c5be

Please sign in to comment.