小编Anj*_*iya的帖子

使用 SwiftUI 设置导航栏标题字体

这是一个 SwiftUI 问题,而不是 UIKit 问题。:)

我正在尝试使用 SwiftUI 为导航栏标题设置不同的字体。我的怀疑是这还不支持。这是我尝试过的:

var body: some View {
  NavigationView {
    .navigationBarTitle(Text("Dashboard").font(.subheadline), displayMode: .large)
  }
}
Run Code Online (Sandbox Code Playgroud)

无论我如何处理.font设置,它都不会改变文本。我还尝试设置自定义字体并删除该displayMode属性。

在此处输入图片说明

有没有人能够让这个工作?

fonts navigationbar swiftui

23
推荐指数
4
解决办法
1万
查看次数

在下次触摸之前无法接收系统手势状态通知

我有一个控件,可以在视图中交替切换两个视图.即,在容器视图中通过子视图方法添加两个视图控制器.缩小gusture缩放当前视图,并显示第二个视图.如果希望转到上一个视图,那么一个捏出来的风就会这样做.问题是,视图doest不会对gusture做出反应,有时并不总是和meessage __CODE__- 在日志中打印出来.任何关于为什么这个消息即将到来并且观点不能反复认可的建议?

- (void)scaleHandler:(UIPinchGestureRecognizer *)gestureRecognizer{

CGFloat currentScale = [[[gestureRecognizer view].layer valueForKeyPath:@"transform.scale"] floatValue];
if([gestureRecognizer state] == UIGestureRecognizerStateBegan) {
    // Reset the last scale, necessary if there are multiple objects with different scales
    lastScale = [gestureRecognizer scale];
}

if ([gestureRecognizer state] == UIGestureRecognizerStateBegan ||
    [gestureRecognizer state] == UIGestureRecognizerStateChanged) {

    // Constants to adjust the max/min values of zoom
    CGFloat kMaxScale = 1.0;
    CGFloat kMinScale = 1.0;
    gestureRecognizer.view.alpha = 1/currentScale;
    if ([gestureRecognizer view] == [self.firstView view]) {
        kMaxScale = 10.0;
        kMinScale …
Run Code Online (Sandbox Code Playgroud)

objective-c uiviewanimation ios uipinchgesturerecognizer

19
推荐指数
1
解决办法
8912
查看次数

访问Sandboxed macOS应用程序中的Apple菜单时出现日志错误

我正在运行刚刚发布的macOS 10.12.2,Xcode 8.2,Swift 3.

我的所有沙盒macOS应用程序中都出现了一个奇怪的错误.当我从Xcode运行应用程序并单击Apple菜单(左上角)时,以下错误记录到Xcode中的控制台:

SandboxViolation: Project-X(3384) deny(1) file-read-data
/Library/Preferences/com.apple.PowerManagement.plist
Run Code Online (Sandbox Code Playgroud)

如果我创建一个版本,将其作为本地应用程序保存到我的Mac并从那里运行它,我看到与macOS控制台中列出的相同的错误,除了在此cfprefsd过程中列为FAULT的错误:

SandboxViolation: Project-X(3384) deny(1) file-read-data
/Library/Preferences/com.apple.PowerManagement.plist
Run Code Online (Sandbox Code Playgroud)

..在这个kernel过程中:

SandboxViolation: Project-X(3384) deny(1) file-read-data
/Library/Preferences/com.apple.PowerManagement.plist
Run Code Online (Sandbox Code Playgroud)

如果我创建没有沙盒的构建,则错误不会显示在任何地方.

我的权利设置只是这两个:

  • App沙盒
  • com.apple.security.files.user-selected.read写

我在10.12.1中遇到了同样的问题,并认为它可能在10.12.2中得到解决,但它仍然存在.这是奇怪的具体,因为只有在应用程序运行时点击Apple菜单才会出现.

非常感谢任何见解.

macos xcode swift

16
推荐指数
1
解决办法
2812
查看次数

SwiftUI更新导航栏标题颜色

如何在SwiftUI中更改导航栏标题颜色

NavigationView {
            List{
                ForEach(0..<15) { item in
                    HStack {
                        Text("Apple")
                            .font(.headline)
                            .fontWeight(.medium)
                            .color(.orange)
                            .lineLimit(1)
                            .multilineTextAlignment(.center)
                            .padding(.leading)
                            .frame(width: 125, height: nil)


                        Text("Apple Infinite Loop. Address: One Infinite Loop Cupertino, CA 95014 (408) 606-5775 ")
                            .font(.subheadline)
                            .fontWeight(.regular)
                            .multilineTextAlignment(.leading)
                            .lineLimit(nil)


                    }
                }
            }
            .navigationBarTitle(Text("TEST")).navigationBarHidden(false).foregroundColor(.orange)
            }
Run Code Online (Sandbox Code Playgroud)

我已经尝试过,.foregroundColor(.orange)但是没有用

也尝试过 .navigationBarTitle(Text("TEST").color(.orange))

有什么帮助吗?

navigationbar ios swiftui

15
推荐指数
12
解决办法
8867
查看次数

如果在swift中按下NSButton,则创建简单的动作

我正在快速学习.我想知道如果按下一个按钮,如何以编程方式调用一个函数....我试过这个,但是当程序启动时直接执行该功能,而不是当我按下按钮时......你能不能帮助我修复这个..谢谢你下面这个测试应用程序的完整ViewController.swift

//
//  ViewController.swift
//  hjkhjkjh
//
//  Created by iznogoud on 14/05/16.
//  Copyright © 2016 iznogoud. All rights reserved.
//

import Cocoa


class ViewController: NSViewController {

    func printSomething() {
       print("Hello")
    }

    override func viewDidLoad() {
       super.viewDidLoad()

       let myButtonRect = CGRect(x: 10, y: 10, width: 100, height: 10)
       let myButton =  NSButton(frame: myButtonRect)
       view.addSubview(myButton)
       myButton.target = self
       myButton.action = Selector(printSomething())


       // Do any additional setup after loading the view.
    }

    override var representedObject: AnyObject? {
       didSet {
          // Update …
Run Code Online (Sandbox Code Playgroud)

selector nsbutton ios swift

13
推荐指数
1
解决办法
8225
查看次数

CocoaPods"target具有包含静态二进制文件的传递依赖"

我正在尝试安装一个我在GitHub上找到的swift框架以及GoogleMaps,GooglePlaces到我的Xcode项目中,但出于某种原因,当我尝试安装pod文件时,它给出了以下错误

[!]'Pods-project1'目标具有包含静态二进制文件的传递依赖:(/ User/user1 /Desktop/project1 /Pods/GoogleMaps/Base/Frameworks/GoogleMapsBase.framework,/ Users/user1/Desktop/project1/Pods /GoogleMaps/Maps/Frameworks/GoogleMaps.framework和/Users/user1/Desktop/project1/Pods/GoogleMaps/Maps/Frameworks/GoogleMapsCore.framework)

这是我正在尝试安装的Pod文件:

#Uncomment the next line to define a global platform for your project
#platform :ios, '9.0'

source 'https://github.com/CocoaPods/Specs.git'

use_frameworks!

target 'project1' do
pod 'GooglePlaces'
pod 'GoogleMaps'
pod 'Google-Maps-iOS-Utils'
pod 'PopupDialog'
end
Run Code Online (Sandbox Code Playgroud)

这里还有我正在尝试安装的swift框架的链接:https: //github.com/Orderella/PopupDialog

我不知道该做什么,我尝试了多种东西,但它们似乎没有用.任何帮助,将不胜感激.

xcode google-maps ios cocoapods swift-framework

9
推荐指数
2
解决办法
6315
查看次数

SwiftUI 中 watchOS 的 NavigationBarTitle 颜色更改

在此处输入图片说明

在上图中,id 喜欢更改-02:49为一种颜色,例如Color.blue

我试过了:

struct ContentView: View {

    var body: some View {
        PlayerView().accentColor(Color.blue)

    }
}
Run Code Online (Sandbox Code Playgroud)

我还尝试将它添加到实际的 PlayerView 中,如下所示:

struct PlayerView: View {

    var body: some View {
        VStack{
            .... 

        }.navigationBarTitle(Text(“-2:49”))
         .accentColor(.blue)

    }

}
Run Code Online (Sandbox Code Playgroud)

我也试过:

   struct PlayerView: View {

    var body: some View {
        VStack{
            .... 

        }.navigationBarTitle(Text(“-2:49”).foregroundColor(.blue))

    }

}
Run Code Online (Sandbox Code Playgroud)

xcode navigationbar swiftui watchos-6

7
推荐指数
3
解决办法
2129
查看次数

在列表 SwiftUI 中拖放以移动行

我正在 SwiftUI 中使用 List。我想在列表中添加拖放行(项目)的功能。在 Swift 中,我们有 UITableView 的 Delegate 和 DataSource 方法,如下所示:

- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath;
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath;
Run Code Online (Sandbox Code Playgroud)

SwiftUI 中这些方法的替代方法是什么?

struct User {
    var firstName: String
    var lastName: String
}

struct UserRow: View {
    var user: User

    var body: some View {
        Text("\(user.firstName) \(user.lastName)")
    }
}

struct ContentView : View {
    var body: some View {

        let user1 = User(firstName: "Anjali", lastName: "User1")
        let user2 = User(firstName: "XYZ", lastName: "User2")

        return List {
            UserRow(user: …
Run Code Online (Sandbox Code Playgroud)

list ios swift swiftui

6
推荐指数
1
解决办法
3715
查看次数

带有备用背景颜色的 SwiftUI 列表

在 SwiftUI 中,TableView 被替换为 List。

有没有办法改变列表单元格/行的背景颜色?

我想实现这样的东西,

if (indexPath.row % 2 == 0) { 
    aCell.backgroundColor = UIColor(red: 0, green: 1, blue: 0, alpha: 1.0) 
}
Run Code Online (Sandbox Code Playgroud)

有关一个很好的例子,请参阅文章https://medium.com/@ronm333/improving-the-appearance-of-ios-tableviews-9effb7184efb

list background-color ios swiftui

6
推荐指数
2
解决办法
2514
查看次数

SwiftUI-如何通过单击键盘上的返回按钮在TextField中导航?

我正在使用SwiftUI的TextField View。我主要有2个问题,

1)在Swift中,我们可以像这样从情节提要中将TextField的Return Key(Text Input Traits)设置Next为TextField吗?为此,在SwiftUI中使用哪个修饰符?

在此处输入图片说明

2)我有两个文本字段,当我单击键盘上的返回/下一步按钮时,如何导航到下一个文本字段?

任何人都可以帮助执行此功能或其他任何替代方法吗?

我的问题是关于SwiftUI而不是UIKit :)

任何帮助将非常感激!!

textfield ios swiftui

6
推荐指数
2
解决办法
831
查看次数