Skip to content

Instantly share code, notes, and snippets.

@Mephsito23
Mephsito23 / gist:677f9583e83a89e8731460a8daded47c
Last active April 7, 2021 06:09
swift 计算字体宽高
extension String {
func height(withConstrainedWidth width: CGFloat, font: UIFont) -> CGFloat {
let constraintRect = CGSize(width: width, height: .greatestFiniteMagnitude)
let boundingBox = self.boundingRect(with: constraintRect, options: .usesLineFragmentOrigin, attributes: [NSAttributedString.Key.font: font], context: nil)
return ceil(boundingBox.height)
}
func width(withConstrainedHeight height: CGFloat, font: UIFont) -> CGFloat {
let constraintRect = CGSize(width: .greatestFiniteMagnitude, height: height)
@Mephsito23
Mephsito23 / ClashForWindows11.3 settings
Last active August 5, 2020 12:16
clashforwindows 11.3 settings
parsers:
- url: https://example.com/example.yaml
code: |
module.exports.parse = (raw, { yaml }) => {
const rawObj = yaml.parse(raw)
const { 'Rule': rules = [], 'Proxy Group':groups = [], 'Proxy': proxies = [] } = rawObj
delete rawObj['Rule']
delete rawObj['Proxy Group']
delete rawObj['Proxy']
return yaml.stringify({ ...rawObj, proxies, 'proxy-groups': groups, rules })
/usr/bin/xcrun xcodebuild -workspace /Users/mac/Desktop/gittub/Water/Carthage/Checkouts/Kingfisher/Kingfisher.xcworkspace -scheme Kingfisher -configuration Release -derivedDataPath /Users/mac/Library/Caches/org.carthage.CarthageKit/DerivedData/9.4.1_9F2000/Kingfisher/5.2.0 -sdk iphoneos ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES archive -archivePath /var/folders/sj/1pkf32d51sv12qw8mfr9rgcw0000gn/T/Kingfisher SKIP_INSTALL=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=NO CLANG_ENABLE_CODE_COVERAGE=NO STRIP_INSTALLED_PRODUCT=NO (launched in /Users/mac/Desktop/gittub/Water/Carthage/Checkouts/Kingfisher)2019-03-14 15:47:09.696 xcodebuild[28808:36902155] WARNING: Failed to load plugin at path: "/Users/mac/Library/Application Support/Developer/Shared/Xcode/Plug-ins/XVim2.xcplugin", skipping. Error: Error Domain=NSCocoaErrorDomain Code=3587 "dlopen_preflight(/Users/mac/Library/Application Support/Developer/Shared/Xcode/Plug-ins/XVim2.xcplugin/Contents/MacOS/XVim2): no suitable image found.
@Mephsito23
Mephsito23 / attributedPlaceholder.m
Created February 22, 2019 09:06
UITextField的Placeholder颜色的三种方式
//第一种
UITextField *textField = [[UITextField alloc] init];
NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:@"请输入占位文字"
attributes:@{NSForegroundColorAttributeName:[UIColor redColor],NSFontAttributeName:textField.font}];
textField.attributedPlaceholder = attrString;
//第二种
UITextField *textField1 = [[UITextField alloc] init];
textField1.placeholder = @"请输入占位文字";
textField1.font = [UIFont systemFontOfSize:14];