I have this source:
import Foundation
import WatchKit
class MyController: WKInterfaceController {
@IBOutlet weak var button: WKInterfaceButton!
override func awakeWithContext(context: AnyObject?) {
super.awakeWithContext(context)
let gradientBlue = UIImage(named: "80x1blueback")
let colorBlue = UIColor(patternImage: gradientBlue!)
self.button.setColor(colorBlue)
}
}
Every variable takes value and the call to:
self.button.setColor(colorBlue)
success. But, after that it crash.
libsystem_kernel.dylib`__pthread_kill: 0x10a6a3278: movl $0x2000148, %eax
0x10a6a327d: movq %rcx, %r10
0x10a6a3280: syscall
0x10a6a3282: jae 0x10a6a328c ; __pthread_kill + 20
0x10a6a3284: movq %rax, %rdi
0x10a6a3287: jmp 0x10a69eca3 ; cerror_nocancel
0x10a6a328c: retq
0x10a6a328d: nop
0x10a6a328e: nop
0x10a6a328f: nop
Marker from Xcode stops at:
0x10a6a3282: jae 0x10a6a328c ; __pthread_kill + 20
The app, keeps running on the watch but this view never gets visible. My image is of 80pixels height, 1 pixel width.
I did test this source on iOS and it works perfectly. So I think it must be something regarding the watch.
Yes, it is possible, although not seems to be possible this way. Actually, it's easier, just that you are not going to see any results on Storyboard and that can make you think that's a no go. This is how:
1.- Set your "image to repeat" (In my case: "80x1blueback" ) on assets of the Watchkit app, (not the extension)
2.- Set your image as the Background of the button (It will not be visible)
3.- Set your Height to anything but "Size to Fit" option.
That's All, Compile and run!