DCOAboutWindow 0.3.1

DCOAboutWindow 0.3.1

测试已测试
语言语言 Obj-CObjective C
许可 BSD-3-Clause
发布最新版本2018年9月

Boy van Amstel维护。



  • Boy van Amstel

概述

DCOAboutWindow 是标准关于对话框的替代品。

它添加了通过点击按钮打开致谢和访问网站的功能。

DCOAboutWindow in action DCOAboutWindow in Dark Mode

显示致谢

您可以将自定义的 Acknowledgments.rtf 文件指向并维护它,或者使用 Acknowledge 这样的脚本来为您生成它。

设置

通过 cocoapods

将以下行添加到您的Podfile中

pod 'DCOAboutWindow'

然后运行 pod install,设置完成。

通过 Carthage

将以下内容添加到您的 Cartfile

github "DangerCove/DCOAboutWindow"

然后运行 carthage update,设置完成。

手动

克隆此仓库并将 DCOAboutWindow 文件夹中的文件添加到您的项目中。

本项目依赖于 DCOTransparentScroller,所以也要包括它。

使用方法

我已经创建了一个与这个小指南相配合的 示例项目

导入 DCOAboutWindowController

#import <DCOAboutWindow/DCOAboutWindowController.h>

实例化 DCOAboutWindow

// Note: make sure self.aboutWindowController is retained
self.aboutWindowController = [[DCOAboutWindowController alloc] init];

创建一个 IBAction 来显示窗口

- (IBAction)showAboutWindow:(id)sender {
  [self.aboutWindowController showWindow:nil];
}

将其连接到 '关于 [app名称]' 菜单项或按钮。

您可以通过在 DCOAboutWindowController 上设置属性来更改值

/**
 *  The application name.
 *  Default: CFBundleName
 */
@property (copy) NSString *appName;

/**
 *  The application version.
 *  Default: "Version %@ (Build %@)", CFBundleVersion, CFBundleShortVersionString
 */
@property (copy) NSString *appVersion;

/**
 *  The copyright line.
 *  Default: NSHumanReadableCopyright
 */
@property (copy) NSString *appCopyright;

/**
 *  The credits.
 *  Default: [[NSBundle mainBundle] pathForResource:@"Credits" ofType:@"rtf"];
 */
@property (copy) NSAttributedString *appCredits;

/**
 *  The URL pointing to the app's website.
 *  Default: none
 */
@property (strong) NSURL *appWebsiteURL;

/**
 *  The path to the file that contains the acknowledgments.
 *  Default: [[NSBundle mainBundle] pathForResource:@"Acknowledgments" ofType:@"rtf"];
 */
@property (nonatomic, copy) NSString *acknowledgmentsPath;

/**
 *  If set to YES acknowledgments are shown in a text view, inside the window. Otherwise an external editor is launched.
 *  Default: NO;
 */
@property (assign) BOOL useTextViewForAcknowledgments;

预处理(针对暗黑模式)

您可以使用委托预先处理包含应用版权信息的 NSAttributedString。这对于使关于窗口与Mission Control的暗黑模式兼容非常有用。以下是操作方法:

// Conform to the DCOStringPreprocessingProtocol
@interface DCDAppDelegate() <DCOStringPreprocessingProtocol>

self.aboutWindowController = [[DCOAboutWindowController alloc] init];
// Set the delegate
self.aboutWindowController.delegate = self;

#pragma mark - DCOStringPreprocessingProtocol

- (NSAttributedString *)preproccessAppCredits:(NSAttributedString *)appCredits {
    NSMutableAttributedString *mutableCredits = [appCredits mutableCopy];
    
    NSDictionary *attributes = @{ NSForegroundColorAttributeName : [NSColor textColor] };
    [mutableCredits setAttributes:attributes range:NSMakeRange(0, mutableCredits.length)];
    
    return [mutableCredits copy];
}

// Optionally pre-process the acknowledgments as well
- (NSAttributedString *)preproccessAppAcknowledgments:(NSAttributedString *)appAcknowledgments {
    NSMutableAttributedString *mutableAcknowledgments = [appAcknowledgments mutableCopy];
    
    NSDictionary *attributes = @{ NSForegroundColorAttributeName : [NSColor textColor] };
    [mutableAcknowledgments setAttributes:attributes range:NSMakeRange(0, mutableCredits.length)];
    
    return [mutableAcknowledgments copy];
}

感谢 @balthisar 添加这个。

本地化

将这些行添加到您的 Localizable.string 以更改这些值或本地化它们。

/* Version %@ (Build %@), displayed in the about window */
"Version %@ (Build %@)" = "v%@ (%@)";

/* Caption on the 'Visit the %@ Website' button in the about window */
"Visit the %@ Website" = "Visit %@'s Website";

/* Caption of the 'Acknowledgments' button in the about window */
"Acknowledgments" = "Acknowledgments";

/* Caption of the 'Credits' button in the about window when acknowledgments are shown when useTextViewForAcknowledgments is YES. */
"Credits" = "Credits";

投稿与新增项

发挥创意。DCOAboutWindow 应当是一个灵活、易用的方式来美化您应用的信息窗口。确保您的更改在没有充分理由的情况下不要破坏现有功能。

要创建拉取请求

  • 复制仓库;
  • 创建新分支 (git checkout -b your-feature);
  • 添加您的代码;
  • 将所有更改提交到您的分支;
  • 推送它 (git push origin your-feature);
  • 通过 GitHub 网页界面提交拉取请求。

分支扩展

如果在您的项目中进行了重大修改,请包括在该部分中。将您自己列入名单并提交给我一个拉取请求。

辅助工具

与 DCOAboutWindow 功能扩展相关联的应用、工具和脚本。

  • Acknowledge - 从 CocoaPods 和自定义 markdown 文件生成单个 Acknowledgments.rtf

变更日志

v0.3.1

  • 使版本字符串可选择的。

v0.3.0

v0.2.0

  • 可选在窗口内显示致谢,而不是通过外部编辑器。

useTextViewForAcknowledgments 设置为 YES 以启用此功能。

  • 改进自动布局约束。现在图像视图保持相同的宽度,而文本字段可以变宽。

v0.1.0

  • 改进了本地化支持
  • 改进了自动布局约束,以更好地处理调整大小

您可以通过设置 NSWindowstyleMask 来切换(默认为关闭)调整大小。查看 示例项目 了解如何使用此功能。

v0.0.2

  • 从使用 'Acknowledgments' 而不是 'Acknowledg_e_ments' 切换,以保持一致性并防止与 Acknowledge 不兼容。注意:请确保更改您的致谢文件名以及任何setter/getter。

v0.0.1

  • 首次发布。

许可权

新的 BSD 许可证,有关详细信息请参阅 LICENSE 文件。