小编Lea*_*Guy的帖子

iOS Swift蓝牙键盘按键检测

在斯威夫特2在iOS 8.4,我怎样检测时,蓝牙键盘的Up,DownSpace按下按键吧,所以我可以用行动回应?示例代码会很有帮助.

keyboard ios swift

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

将Object-C转换为SWIFT textKit

我的应用程序中使用了以下代码来更改textview中text和big和italic之间的状态.我一直试图在Swift中重写它,但我不断收到编译错误.以下是在线教程中提供给我的Objective-C版本.接下来是我的新swift版本,直到该方法崩溃.
我会推荐任何帮助我理解为什么编译器抱怨这么多的帮助.

-(void)addOrRemoveFontTraitWithName:(NSString *)traitName andValue:(uint32_t)traitValue{
NSRange selectedRange = [_field2 selectedRange];


NSDictionary *currentAttributesDict = [_field2.textStorage attributesAtIndex:selectedRange.location
                                                                effectiveRange:nil];


UIFont *currentFont = [currentAttributesDict objectForKey:NSFontAttributeName];
UIColor *currentColor = [currentAttributesDict objectForKey:NSForegroundColorAttributeName];
UIColor *currentBGColor = [currentAttributesDict objectForKey:NSBackgroundColorAttributeName];
UIFont *currentUnderlinedText = [currentAttributesDict objectForKey:NSUnderlineStyleAttributeName];
NSMutableParagraphStyle *currentparagraphStyle = [currentAttributesDict objectForKey:NSParagraphStyleAttributeName];    //receive and set new font name



UIFontDescriptor *fontDescriptor = [currentFont fontDescriptor];


NSString *fontNameAttribute = [[fontDescriptor fontAttributes] objectForKey:UIFontDescriptorNameAttribute];
UIFontDescriptor *changedFontDescriptor;

if ([fontNameAttribute rangeOfString:traitName].location == NSNotFound) {


    uint32_t existingTraitsWithNewTrait = [fontDescriptor symbolicTraits] | traitValue;
    changedFontDescriptor = [fontDescriptor fontDescriptorWithSymbolicTraits:existingTraitsWithNewTrait];

}
else{
    uint32_t …
Run Code Online (Sandbox Code Playgroud)

objective-c ios swift uifontdescriptor

-2
推荐指数
1
解决办法
388
查看次数

标签 统计

ios ×2

swift ×2

keyboard ×1

objective-c ×1

uifontdescriptor ×1