Skip to content
This repository has been archived by the owner on May 3, 2020. It is now read-only.

Commit

Permalink
Custom First TableView 👍
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreBrisorgueil committed Apr 26, 2015
1 parent 8b1a5be commit 3323701
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 10 deletions.
24 changes: 15 additions & 9 deletions StepOne/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="64" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="n2N-2V-g4t">
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="n2N-2V-g4t">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="SearchResultCell" textLabel="Fah-cI-g5K" detailTextLabel="s0n-Bn-OWb" style="IBUITableViewCellStyleValue1" id="Og4-71-dsZ">
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" showsReorderControl="YES" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="SearchResultCell" textLabel="Fah-cI-g5K" detailTextLabel="RgX-Yp-FY4" style="IBUITableViewCellStyleSubtitle" id="Og4-71-dsZ">
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Og4-71-dsZ" id="a7A-N9-Tcs">
<autoresizingMask key="autoresizingMask"/>
Expand All @@ -32,14 +32,15 @@
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="s0n-Bn-OWb">
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Detail" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="RgX-Yp-FY4">
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="0.55686274509803924" green="0.55686274509803924" blue="0.57647058823529407" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="11"/>
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
<inset key="separatorInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
<connections>
<segue destination="ueX-TJ-urU" kind="show" id="cUF-hl-4Pd"/>
</connections>
Expand All @@ -62,6 +63,7 @@
<navigationItem key="navigationItem" title="Search" id="FdQ-zg-kvb"/>
<connections>
<outlet property="appsTableView" destination="n2N-2V-g4t" id="EgG-bu-ZeH"/>
<outlet property="mytable" destination="n2N-2V-g4t" id="JSB-Go-ovu"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
Expand All @@ -77,7 +79,7 @@
<viewControllerLayoutGuide type="bottom" id="axv-Lc-av4"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="rNY-FG-wcW">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="64" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="WcI-bt-O13">
Expand Down Expand Up @@ -155,6 +157,7 @@
</view>
<connections>
<outlet property="albumCover" destination="WcI-bt-O13" id="ebA-eY-e0A"/>
<outlet property="myView" destination="rNY-FG-wcW" id="JEa-2s-Vuq"/>
<outlet property="titleLabel" destination="uRI-e1-i7b" id="Jin-I4-hzU"/>
<outlet property="tracksTableView" destination="K8u-7L-5bx" id="7lr-Bv-NUI"/>
</connections>
Expand All @@ -168,9 +171,12 @@
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="EHi-pr-nrX" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="lZ3-Fi-h4N">
<simulatedStatusBarMetrics key="simulatedStatusBarMetrics" statusBarStyle="lightContent"/>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" barStyle="black" prompted="NO"/>
<navigationBar key="navigationBar" contentMode="scaleToFill" barStyle="black" id="lZ3-Fi-h4N">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<color key="tintColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
Expand All @@ -179,7 +185,7 @@
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="B2p-XM-2Qy" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="505" y="389"/>
<point key="canvasLocation" x="685" y="389"/>
</scene>
</scenes>
</document>
2 changes: 2 additions & 0 deletions StepOne/DetailsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class DetailsViewController: UIViewController, APIControllerProtocol {
@IBOutlet weak var albumCover: UIImageView!
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var tracksTableView: UITableView!
@IBOutlet var myView: UIView!

// Var
/*************************/
Expand All @@ -40,6 +41,7 @@ class DetailsViewController: UIViewController, APIControllerProtocol {
/*************************/
override func viewDidLoad() {
super.viewDidLoad()
// get data
titleLabel.text = self.album?.title
albumCover.image = UIImage(data: NSData(contentsOfURL: NSURL(string: self.album!.largeImageURL)!)!)
// Load in tracks
Expand Down
Binary file added StepOne/Images.xcassets/home.imageset/1-1.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added StepOne/Images.xcassets/home.imageset/1-2.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added StepOne/Images.xcassets/home.imageset/1.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions StepOne/Images.xcassets/home.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "1.jpg"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "1-1.jpg"
},
{
"idiom" : "universal",
"scale" : "3x",
"filename" : "1-2.jpg"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
21 changes: 20 additions & 1 deletion StepOne/SearchResultsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class SearchResultsViewController: UIViewController, UITableViewDataSource, UITa
// Boulet
/*************************/
@IBOutlet weak var appsTableView: UITableView!
@IBOutlet weak var mytable: UITableView!

// Var
/*************************/
Expand All @@ -31,6 +32,11 @@ class SearchResultsViewController: UIViewController, UITableViewDataSource, UITa
/*************************/
override func viewDidLoad() {
super.viewDidLoad()
// custom
self.mytable.rowHeight = 70
self.mytable.backgroundView = UIImageView(image: UIImage(named: "home.jpg"))

// get data
api = APIController(delegate: self)
UIApplication.sharedApplication().networkActivityIndicatorVisible = true
api.searchItunesFor("Beatles")
Expand Down Expand Up @@ -89,9 +95,22 @@ class SearchResultsViewController: UIViewController, UITableViewDataSource, UITa
}
})
}

// custom
cell.detailTextLabel?.backgroundColor = UIColor.whiteColor().colorWithAlphaComponent(0)
cell.detailTextLabel?.textColor = UIColor.whiteColor().colorWithAlphaComponent(0.7)
cell.textLabel?.backgroundColor = UIColor.whiteColor().colorWithAlphaComponent(0)
cell.textLabel?.textColor = UIColor.whiteColor()
cell.backgroundColor = UIColor.blackColor().colorWithAlphaComponent(0.50)

// custom selected cell
let customColorView = UIView()
customColorView.backgroundColor = UIColor.blackColor().colorWithAlphaComponent(0.1)
cell.selectedBackgroundView = customColorView

return cell
}

func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
cell.layer.transform = CATransform3DMakeScale(0.1,0.1,1)
UIView.animateWithDuration(0.25, animations: {
Expand Down

0 comments on commit 3323701

Please sign in to comment.