Skip to content

Commit

Permalink
170829 별이미지 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
wooooooong committed Aug 29, 2017
1 parent 2dbb3b4 commit d39d671
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 45 deletions.
24 changes: 12 additions & 12 deletions iOSProject/pyunrihae/pyunrihae/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="253" translatesAutoresizingMaskIntoConstraints="NO" id="cly-4C-f2a">
<rect key="frame" x="183" y="57" width="80" height="21"/>
<rect key="frame" x="183" y="54" width="80" height="21"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="E4e-y2-Xbg"/>
<constraint firstAttribute="width" constant="80" id="pgC-9e-AWc"/>
Expand Down Expand Up @@ -614,9 +614,9 @@
<constraint firstItem="q0B-Uv-CQ7" firstAttribute="top" secondItem="o0K-rL-XjS" secondAttribute="top" id="NLE-mS-VPC"/>
<constraint firstAttribute="bottomMargin" secondItem="nuP-SV-grC" secondAttribute="bottom" constant="12" id="NOF-2F-jie"/>
<constraint firstItem="5Qe-nm-Vek" firstAttribute="top" secondItem="JvE-m9-zGk" secondAttribute="bottom" constant="9" id="UAO-MO-ySS"/>
<constraint firstItem="yK6-Sy-hLu" firstAttribute="top" secondItem="cly-4C-f2a" secondAttribute="top" id="anM-8a-QDJ"/>
<constraint firstItem="nuP-SV-grC" firstAttribute="leading" secondItem="D3A-qB-grp" secondAttribute="trailing" constant="15" id="czG-EW-Sfu"/>
<constraint firstItem="PLx-iE-b3f" firstAttribute="leading" secondItem="q0B-Uv-CQ7" secondAttribute="trailing" constant="5" id="d80-yZ-XCh"/>
<constraint firstItem="cly-4C-f2a" firstAttribute="top" secondItem="b7P-Vs-4Ot" secondAttribute="bottom" constant="12" id="f47-n2-TMW"/>
<constraint firstItem="yK6-Sy-hLu" firstAttribute="leading" secondItem="cly-4C-f2a" secondAttribute="trailing" constant="10" id="f8Z-rA-ZBA"/>
<constraint firstItem="ILA-6R-yMQ" firstAttribute="leading" secondItem="ylF-Bu-Y03" secondAttribute="leadingMargin" constant="11" id="grN-em-pAm"/>
<constraint firstItem="nxo-bd-EGt" firstAttribute="leading" secondItem="5Qe-nm-Vek" secondAttribute="trailing" constant="31" id="hXe-lv-AmJ"/>
Expand Down Expand Up @@ -943,7 +943,7 @@
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="rld-Hj-nwR">
<rect key="frame" x="236" y="19" width="80" height="21"/>
<rect key="frame" x="236" y="16" width="80" height="21"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="4OL-8U-ujf"/>
<constraint firstAttribute="width" constant="80" id="ckL-wA-y9r"/>
Expand All @@ -955,7 +955,7 @@
<constraint firstItem="sus-Zi-hSx" firstAttribute="top" secondItem="Qq6-OC-Ey9" secondAttribute="bottom" constant="7" id="2IL-k8-Os2"/>
<constraint firstItem="Qq6-OC-Ey9" firstAttribute="top" secondItem="BRW-gA-aWd" secondAttribute="bottom" constant="7" id="4bl-Xo-fIM"/>
<constraint firstItem="Wgy-sd-NF0" firstAttribute="top" secondItem="Px1-gv-3Q7" secondAttribute="bottom" constant="7" id="C0E-SE-pWx"/>
<constraint firstItem="rld-Hj-nwR" firstAttribute="top" secondItem="oTu-zk-F13" secondAttribute="topMargin" constant="11" id="Cr7-Dt-bHp"/>
<constraint firstItem="rld-Hj-nwR" firstAttribute="top" secondItem="oTu-zk-F13" secondAttribute="topMargin" constant="8" id="Cr7-Dt-bHp"/>
<constraint firstAttribute="trailingMargin" secondItem="rld-Hj-nwR" secondAttribute="trailing" constant="51" id="D1E-MZ-yxr"/>
<constraint firstAttribute="trailingMargin" secondItem="coX-Gl-Ppg" secondAttribute="trailing" constant="10" id="EbS-Vr-WBc"/>
<constraint firstAttribute="bottom" secondItem="Wgy-sd-NF0" secondAttribute="bottom" constant="45.666666666666657" id="JpE-YI-Rbm"/>
Expand Down Expand Up @@ -2290,21 +2290,21 @@
<color key="textColor" red="0.50196081400000003" green="0.50196081400000003" blue="0.50196081400000003" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="4.88" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="B7u-Mk-brM">
<rect key="frame" x="8" y="32" width="35" height="21"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="4.8" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="B7u-Mk-brM">
<rect key="frame" x="8" y="32" width="25" height="21"/>
<constraints>
<constraint firstAttribute="width" constant="35" id="OBC-3q-ESG"/>
<constraint firstAttribute="width" constant="25" id="OBC-3q-ESG"/>
<constraint firstAttribute="height" constant="21" id="yGn-KN-5dd"/>
</constraints>
<fontDescription key="fontDescription" type="boldSystem" pointSize="13"/>
<color key="textColor" red="1" green="0.5" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="IYe-F8-fjR">
<rect key="frame" x="43" y="28" width="70" height="25"/>
<rect key="frame" x="33" y="30" width="80" height="25"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="dPv-Co-IRu">
<rect key="frame" x="0.0" y="0.0" width="70" height="25"/>
<rect key="frame" x="0.0" y="0.0" width="80" height="25"/>
</imageView>
</subviews>
<color key="backgroundColor" white="1" alpha="0.0" colorSpace="calibratedWhite"/>
Expand All @@ -2314,7 +2314,7 @@
<constraint firstItem="dPv-Co-IRu" firstAttribute="top" secondItem="IYe-F8-fjR" secondAttribute="top" id="BMk-Oz-yPp"/>
<constraint firstAttribute="bottom" secondItem="dPv-Co-IRu" secondAttribute="bottom" id="VmV-SX-BVY"/>
<constraint firstAttribute="height" constant="25" id="ko5-hU-e3s"/>
<constraint firstAttribute="width" constant="70" id="koK-48-HAb"/>
<constraint firstAttribute="width" constant="80" id="koK-48-HAb"/>
</constraints>
</view>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="back_right.png" translatesAutoresizingMaskIntoConstraints="NO" id="cSQ-BP-Epc">
Expand Down Expand Up @@ -2374,7 +2374,7 @@
<constraint firstItem="dkm-wv-gZC" firstAttribute="leading" secondItem="oth-3A-jDp" secondAttribute="leading" constant="8" id="Q5v-HH-Ry0"/>
<constraint firstItem="4EX-RX-uxo" firstAttribute="centerY" secondItem="WVO-0x-4Gf" secondAttribute="centerY" id="Rw6-7v-Vcg"/>
<constraint firstAttribute="bottom" secondItem="cSQ-BP-Epc" secondAttribute="bottom" constant="10" id="aX3-Oe-mK9"/>
<constraint firstItem="IYe-F8-fjR" firstAttribute="top" secondItem="WVO-0x-4Gf" secondAttribute="bottom" constant="4" id="goY-Rz-r1L"/>
<constraint firstItem="IYe-F8-fjR" firstAttribute="top" secondItem="WVO-0x-4Gf" secondAttribute="bottom" constant="5.5" id="goY-Rz-r1L"/>
<constraint firstItem="WVO-0x-4Gf" firstAttribute="leading" secondItem="dkm-wv-gZC" secondAttribute="trailing" constant="8" id="i6Z-K4-w6A"/>
<constraint firstItem="LJI-XV-1eO" firstAttribute="top" secondItem="WVO-0x-4Gf" secondAttribute="bottom" constant="8" id="jYh-rq-Sy0"/>
<constraint firstItem="B7u-Mk-brM" firstAttribute="leading" secondItem="oth-3A-jDp" secondAttribute="leading" constant="8" id="m7Q-Kz-Ize"/>
Expand Down Expand Up @@ -2933,7 +2933,7 @@
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="Tjj-5D-81b" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" misplaced="YES" id="gmW-rw-qvv">
<navigationBar key="navigationBar" contentMode="scaleToFill" id="gmW-rw-qvv">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
Expand Down
57 changes: 24 additions & 33 deletions iOSProject/pyunrihae/pyunrihae/Image.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,36 @@ class Image {
image.layer.cornerRadius = image.layer.frame.height/2
image.clipsToBounds = true
}
static func drawStar(numberOfPlaces: Double, grade_avg: Double, gradeLabel: UILabel, starView: UIView) {
static func drawStar(numberOfPlaces: Double, grade_avg: Double, gradeLabel: UILabel, starView: UIImageView) {
for sub in starView.subviews {
sub.removeFromSuperview()
}
let multiplier = pow(10.0, numberOfPlaces)
let grade = round(Double(grade_avg) * multiplier) / multiplier
gradeLabel.text = String(grade)
if grade - Double(Int(grade)) >= 0.5 {
let starImage = UIImage(named: "stars.png")
let cgImage = starImage?.cgImage
let croppedCGImage: CGImage = cgImage!.cropping(to: CGRect(x: (starImage?.size.width)! * 4 / 5, y: 10, width: (starImage?.size.width)!, height: starImage!.size.height))!
let uiImage = UIImage(cgImage: croppedCGImage)
let imageView = UIImageView(image: uiImage)
imageView.frame = CGRect(x: Int(grade) * 18 - 3, y: 0, width: 17, height: 15)
starView.addSubview(imageView)
for i in (Int(grade) + 1)..<5 {
let emptyStarImage = UIImage(named: "empty_star.png")
let imageView = UIImageView(image: emptyStarImage)
imageView.contentMode = .scaleAspectFit
imageView.frame = CGRect(x: i * 18 - 3, y: 0, width: 17, height: 15)
starView.addSubview(imageView)
}
} else{
for i in Int(grade)..<5 {
let emptyStarImage = UIImage(named: "empty_star.png")
let imageView = UIImageView(image: emptyStarImage)
imageView.contentMode = .scaleAspectFit
imageView.frame = CGRect(x: i * 18 - 3, y: 0, width: 17, height: 15)
starView.addSubview(imageView)
}
}
for i in 0..<Int(grade) {
let starImage = UIImage(named: "stars.png")
let cgImage = starImage?.cgImage
let croppedCGImage: CGImage = cgImage!.cropping(to: CGRect(x: 0, y: 10, width: (starImage?.size.width)! / 5, height: starImage!.size.height))!
let uiImage = UIImage(cgImage: croppedCGImage)
let imageView = UIImageView(image: uiImage)
imageView.frame = CGRect(x: i * 18, y: 0, width: 17, height: 15)
starView.addSubview(imageView)
starView.contentMode = .scaleAspectFit
if grade < 0.5 {
starView.image = UIImage(named: "star0.png")
} else if grade < 1.0 {
starView.image = UIImage(named: "star5.png")
} else if grade < 1.5 {
starView.image = UIImage(named: "star1.png")
} else if grade < 2.0 {
starView.image = UIImage(named: "star15.png")
} else if grade < 2.5 {
starView.image = UIImage(named: "star2.png")
} else if grade < 3.0 {
starView.image = UIImage(named: "star25.png")
} else if grade < 3.5 {
starView.image = UIImage(named: "star3.png")
} else if grade < 4.0 {
starView.image = UIImage(named: "star35.png")
} else if grade < 4.5 {
starView.image = UIImage(named: "star4.png")
} else if grade < 5.0 {
starView.image = UIImage(named: "star45.png")
} else if grade == 5.0 {
starView.image = UIImage(named: "star5.png")
}
}
}
2 changes: 2 additions & 0 deletions iOSProject/pyunrihae/pyunrihae/Popup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class Popup{
btns.validator = validator
btns.badBtn.isEnabled = false
btns.usefulBtn.isEnabled = false
Button.deleteBorder(btn: btns.usefulBtn)
Button.deleteBorder(btn: btns.badBtn)
DataManager.getReviewBy(id: review.id){ (review) in
btns.badNumLabel.text = String(review.bad)
btns.usefulNumLabel.text = String(review.useful)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class ProductReviewTableViewCell: UITableViewCell {
btns.backgroundColor = UIColor.white.withAlphaComponent(0)
btns.badBtn.isEnabled = false
btns.usefulBtn.isEnabled = false
Button.deleteBorder(btn: btns.usefulBtn)
Button.deleteBorder(btn: btns.badBtn)
DataManager.getReviewBy(id: review.id){ (review) in
btns.badNumLabel.text = String(review.bad)
btns.usefulNumLabel.text = String(review.useful)
Expand Down

0 comments on commit d39d671

Please sign in to comment.