iOS 7 后退按钮符号?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18753864/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
iOS 7 Back Button Symbol?
提问by ZuluDeltaNiner
I really like the shape of the back button arrow in iOS 7, and would like to use it on one of my UIButtons, but like > instead of <. Would there be a way with text, or should I just use images?
我真的很喜欢 iOS 7 中后退按钮箭头的形状,并想在我的一个 UIButton 上使用它,但喜欢 > 而不是 <。有没有文字的方法,还是我应该只使用图像?
回答by jungledev
You have to use an image. These assets are in the original size from Apple. Here you go, simply right-click and save each one.
1x:
您必须使用图像。这些资源是 Apple 提供的原始尺寸。在这里,只需右键单击并保存每个。
1 倍:
回答by Stephan Burlot
You can extract all iOS7 artwork using Cédric Luthi's iOS-Artwork-Extractoravailable on GitHub: compile this app in the simulator and look for UINavigationBarBackDefault.png.
您可以使用GitHub 上提供的Cédric Luthi 的iOS-Artwork-Extractor提取所有 iOS7 艺术作品:在模拟器中编译此应用程序并查找 UINavigationBarBackDefault.png。
The picture is .
图片是。
An alternative is to get the Teehan + Lax iOS7 GUI PSD (iPhone)file. It contains most of iOS7 artwork. There's also a Sketch Appversion: Teehan + Lax iOS7 GUI for Sketch.
另一种方法是获取Teehan + Lax iOS7 GUI PSD (iPhone)文件。它包含大部分 iOS7 艺术作品。还有一个Sketch App版本:Teehan + Lax iOS7 GUI for Sketch。
回答by jakob.j
My solution is to use a Unicode character as back button icon:
我的解决方案是使用 Unicode 字符作为后退按钮图标:
?
?
SINGLE LEFT-POINTING ANGLE QUOTATION MARK Unicode: U+2039, UTF-8: E2 80 B9
单左指角引号 Unicode: U+2039, UTF-8: E2 80 B9
HTML Entity: ‹
HTML实体: ‹
Drawback:
退税:
- Does not exactly look like the real back button icon, but close enough for me
- 看起来不像真正的后退按钮图标,但对我来说足够接近
Advantages:
好处:
- Simple and quick to implement
- No image file needed
- Thus, the color of the back button icon is not fixed but may get adjusted by color design changes / new versions of iOS
- 实施简单快捷
- 不需要图像文件
- 因此,后退按钮图标的颜色不是固定的,但可能会通过颜色设计更改/新版本的 iOS 进行调整
Instructions:
指示:
- Show the OS X Character Viewer (next to the clock, maybe you have to activate it in Preferences -> Keyboard)
- In the left list, click on "Parentheses"
- In Xcode, place your text cursor inside the string you define as back button text
- In the Character Viewer, click on the first entry in the third row (I had to click a few times until it was inserted in Xcode)
- 显示 OS X 字符查看器(在时钟旁边,也许您必须在首选项 -> 键盘中激活它)
- 在左侧列表中,单击“括号”
- 在 Xcode 中,将文本光标放在您定义为后退按钮文本的字符串内
- 在 Character Viewer 中,点击第三行的第一个条目(我不得不点击几次,直到它被插入到 Xcode 中)
Maybe there are even better characters which look like the back button icon...
也许还有更好的字符看起来像后退按钮图标......
回答by Pup
Official Apple back button symbol artwork can be downloaded at https://developer.apple.com/ios/human-interface-guidelines/resources/
官方 Apple 后退按钮符号艺术品可在https://developer.apple.com/ios/human-interface-guidelines/resources/下载
回答by Fattie
Copy and paste.
复制和粘贴。
Make the view 32 x 32.
使视图为32 x 32。
For the position, iOS usual position is 24 from the left safe area.
对于位置,iOS 通常的位置是距离左侧安全区 24 的位置。
@IBDesignable class BackArrow32Button: UIButton {
override func draw(_ rect: CGRect) {
//
// this is just carefully MATCHED to the Apple one (2019)
// make the box > 32x32 < and have it > 24 on the left from safe area <
//
let bezierPath = UIBezierPath()
bezierPath.move(to: CGPoint(x: 17, y: 6))
bezierPath.addLine(to: CGPoint(x: 7, y: 16))
bezierPath.addLine(to: CGPoint(x: 17, y: 26))
UIColor.black.setStroke()
bezierPath.lineWidth = 3
bezierPath.stroke()
}
}
A detail ...
一个细节...
I didn't add intrinsic content size, since,
我没有添加内在内容大小,因为,
(A) it's probably easier for newer programmers like this
(A) 对于像这样的新程序员来说可能更容易
(B) generally speaking intrinsic size is just broken on interface builder, so for an easy life you're better to just put in the height and width with a constraint :/
(B) 一般来说,界面构建器上的内在尺寸刚刚被破坏,所以为了轻松的生活,你最好只在高度和宽度上加上一个约束:/
回答by rnr-a-np
i meant to answer this question:
我想回答这个问题:
Creating a left-arrow button (like UINavigationBar's "back" style) on a UIToolbar
在 UIToolbar 上创建左箭头按钮(如 UINavigationBar 的“后退”样式)
(inspired by machoota's answer there), but it's locked, and, being new, i don't have the rep ... anyway, swiftui version:
(受到 machoota 在那里的回答的启发),但它已锁定,而且,作为新人,我没有代表……无论如何,swiftui 版本:
struct BackArrow: View
{
@Environment(\.horizontalSizeClass) var hsc: UserInterfaceSizeClass?
@Environment(\.verticalSizeClass) var vsc: UserInterfaceSizeClass?
var color: Color
var body: some View {
Path { path in
let height = self.arrowHeight(h: self.hsc, v: self.vsc)
let width = height * 0.6
path.move(to: CGPoint(x: width * 5.0 / 6.0, y: height * 0.0 / 10.0))
path.addLine(to: CGPoint(x: width * 0.0 / 6.0, y: height * 5.0 / 10.0))
path.addLine(to: CGPoint(x: width * 5.0 / 6.0, y: height * 10.0 / 10.0))
path.addQuadCurve( to: CGPoint( x: width * ((6.0 / 6.0) + self.fudgeFactor(h: self.hsc, v: self.vsc)),
y: height * ((9.0 / 10.0) - (self.fudgeFactor(h: self.hsc, v: self.vsc) * 1.666666))),
control: CGPoint( x: width * ((6.0 / 6.0) + self.fudgeFactor(h: self.hsc, v: self.vsc)),
y: height * 10.0 / 10.0))
path.addLine(to: CGPoint( x: width * ((2.0 / 6.0) + (3 * self.fudgeFactor(h: self.hsc, v: self.vsc))),
y: height * 5.0 / 10.0))
path.addLine(to: CGPoint( x: width * ((6.0 / 6.0) + self.fudgeFactor(h: self.hsc, v: self.vsc)),
y: height * ((1.0 / 10.0) + (self.fudgeFactor(h: self.hsc, v: self.vsc) * 1.666666))))
path.addQuadCurve( to: CGPoint( x: width * 5.0 / 6.0,
y: height * 0.0 / 10.0),
control: CGPoint( x: width * ((6.0 / 6.0) + self.fudgeFactor(h: self.hsc, v: self.vsc)),
y: height * 0.0 / 10.0))
}
.fill(color)
.offset(x: -8.0, y: -5.0) // there's probaby some better way to figure this out, but i've wasted too much time already ...
}
private func fudgeFactor(h: UserInterfaceSizeClass?, v: UserInterfaceSizeClass?) -> CGFloat
{ return h == .compact ? ( v == .compact ? 0.01 // (c, c): normal phone, landscape
: 0.003 ) // (c, r): any phone, portrait
: ( v == .compact ? 0.01 // (r, c): large phone, landscape
: 0.003 ) // (r, r): ipad, full-screen, any
}
private func arrowHeight(h: UserInterfaceSizeClass?, v: UserInterfaceSizeClass?) -> CGFloat
{ return h == .compact ? ( v == .compact ? 18.0 // (c, c): normal phone, landscape
: 21.0 ) // (c, r): any phone, portrait
: ( v == .compact ? 18.0 // (r, c): large phone, landscape
: 21.0 ) // (r, r): ipad, full-screen, any
}
}
it's a filthy hack, but then again, trying to do anything remotely custom in swiftui feels pretty hacky right now anyway ...
这是一个肮脏的黑客,但话又说回来,尝试在 swiftui 中远程定制任何东西现在感觉很hacky 无论如何......
回答by rnr-a-np
This would best be achieved through the usage of images. There is no way to do this with text, sorry.
这最好通过使用图像来实现。没有办法用文本来做到这一点,抱歉。
I was able to find this image, it's a .png
我能找到这张图片,这是一个 .png