From bd64906f19bb664911c3d2793cfe10c47a753332 Mon Sep 17 00:00:00 2001 From: masakih Date: Thu, 27 Jul 2017 22:28:21 +0900 Subject: [PATCH] =?utf8?q?=E5=87=A6=E7=90=86=E3=82=92=E7=B0=A1=E7=B4=A0?= =?utf8?q?=E5=8C=96=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- KCD/SuppliesCell.swift | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/KCD/SuppliesCell.swift b/KCD/SuppliesCell.swift index 6f0aca45..bc8113de 100644 --- a/KCD/SuppliesCell.swift +++ b/KCD/SuppliesCell.swift @@ -67,9 +67,8 @@ final class SuppliesCell: NSCell { private func drawBackground(withFrame cellFrame: NSRect) { - let path = NSBezierPath(rect: cellFrame) borderColor.set() - path.fill() + NSBezierPath(rect: cellFrame).fill() } private func color(of type: ResourceType, position: Int, border: Int) -> NSColor { @@ -85,12 +84,11 @@ final class SuppliesCell: NSCell { let width: CGFloat = (cellFrame.width - CGFloat(numberOfCell) - 1.0) / CGFloat(numberOfCell) let y: CGFloat = type == .fuel ? height + 2.0 : 1.0 - // TODO: use forEach - for i in 0...10 { + (0...numberOfCell).forEach { - let x: CGFloat = CGFloat(1 + i) + width * CGFloat(i) + let x: CGFloat = CGFloat(1 + $0) + width * CGFloat($0) let cellRect = NSRect(x: x, y: y, width: width, height: height) - color(of: type, position: i, border: border).set() + color(of: type, position: $0, border: border).set() NSBezierPath(rect: cellRect).fill() } } -- 2.11.0