小编Arc*_*rch的帖子

如何显示分数文本数量?

我需要在我的应用程序中显示一小部分,但找不到一个好方法吗?

应该看起来像这样

在此输入图像描述(概念证明......不需要字体):

还有其他类似的帖子,但它们在ObJ C中,我找不到一个可靠的解决方案

fractions swift

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

如何按颜色对UIColors数组进行排序(以ROYGBIV顺序为例)?

我有一大堆颜色要在我的UI中显示在一个数组中,我认为如果它们按颜色排序会看起来最好.我该怎么做呢?

swift

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

是否有更好的方法将自定义类保存到NSUserDefaults而不是使用NSCoder编码和解码所有内容?

我当前的类有大约50行只是编码和解码变量,以便我的类与NSUserDefaults兼容.有没有更好的方法来处理这个?

例:

 init(coder aDecoder: NSCoder!) {
    lightEnabled = aDecoder.decodeBoolForKey("lightEnabled")
    soundEnabled = aDecoder.decodeBoolForKey("soundEnabled")
    vibrateEnabled = aDecoder.decodeBoolForKey("vibrateEnabled")
    pulseEnabled = aDecoder.decodeBoolForKey("pulseEnabled")
    songs = aDecoder.decodeObjectForKey("songs") as! [Song]
    currentSong = aDecoder.decodeIntegerForKey("currentSong")
    enableBackgroundSound = aDecoder.decodeBoolForKey("enableBackgroundSound")
    mixSound = aDecoder.decodeBoolForKey("mixSound")
    playSoundInBackground = aDecoder.decodeBoolForKey("playSoundInBackground")
    duckSounds = aDecoder.decodeBoolForKey("duckSounds")
    BPMBackground = NSKeyedUnarchiver.unarchiveObjectWithData(aDecoder.decodeObjectForKey("BPMBackgorund") as! NSData) as! UIColor!
    BPMPulseColor = NSKeyedUnarchiver.unarchiveObjectWithData(aDecoder.decodeObjectForKey("BPMPulseColor") as! NSData) as! UIColor!
    TempoBackGround = NSKeyedUnarchiver.unarchiveObjectWithData(aDecoder.decodeObjectForKey("TempoBackGround") as! NSData) as! UIColor!
    TempoPulseColor = NSKeyedUnarchiver.unarchiveObjectWithData(aDecoder.decodeObjectForKey("TempoPulseColor") as! NSData) as! UIColor!
    TimeBackGround = NSKeyedUnarchiver.unarchiveObjectWithData(aDecoder.decodeObjectForKey("TimeBackGround") as! NSData) as! UIColor!
    TimeStrokeColor = NSKeyedUnarchiver.unarchiveObjectWithData(aDecoder.decodeObjectForKey("TimeStrokeColor") as! NSData) as! UIColor! …
Run Code Online (Sandbox Code Playgroud)

archiving nsuserdefaults ios swift

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

标签 统计

swift ×3

archiving ×1

fractions ×1

ios ×1

nsuserdefaults ×1