我是Android的新手,我有这段代码强调了SpannableString。我想修改对象UnderlineSpan(),以便它覆盖Spannablestring而不是加下划线。所以基本上我希望它在字符串上而不是在字符串下面。我怎么能做到这一点?有没有其他方法可以做到这一点?感谢
import SpriteKit
import iAd
import StoreKit
var list = [SKProduct]()
var p = SKProduct()
class GameScene: SKScene, ADInterstitialAdDelegate, SKProductsRequestDelegate, SKPaymentTransactionObserver {
getProductInfo()
}
func getProductInfo() {
if(SKPaymentQueue.canMakePayments()) {
print("IAP is enabled, loading")
var productID:NSSet = NSSet(objects: "remove_ads")
let request: SKProductsRequest = SKProductsRequest(productIdentifiers: productID as! Set<String>)
request.delegate = self
request.start()
} else {
print("please enable IAPS")
}
}
func buyProduct() {
print("buy " + p.productIdentifier)
var pay = SKPayment(product: p)
SKPaymentQueue.defaultQueue().addTransactionObserver(self)
SKPaymentQueue.defaultQueue().addPayment(pay as SKPayment)
}
func paymentQueue(queue: SKPaymentQueue, updatedDownloads downloads: [SKDownload]) {
}
func paymentQueue(queue: SKPaymentQueue, removedTransactions transactions: [SKPaymentTransaction]) {
}
func paymentQueue(queue: SKPaymentQueue, res toreCompletedTransactionsFailedWithError error: NSError) {
}
func paymentQueue(queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
}
func productsRequest (request: SKProductsRequest, didReceiveResponse response: SKProductsResponse) {
print("product request")
var myProduct = response.products
for product in myProduct {
print("product added")
print(product.productIdentifier)
print(product.localizedTitle)
print(product.localizedDescription)
print(product.price)
list.append(product as! SKProduct )
}
}
func paymentQueueRestoreCompletedTransactionsFinished(queue: SKPaymentQueue!) {
print("transactions restored")
var purchasedItemIDS = []
for transaction in queue.transactions {
var t: SKPaymentTransaction = transaction as! SKPaymentTransaction
let prodID = t.payment.productIdentifier as String
switch prodID {
case "IAP id here": break
default:
print("IAP not setup")
}
}
var alert = UIAlertView(title: "Thank You", message: "Your purchase(s) were restored. You may have to restart the app before banner ads are removed.", delegate: nil, cancelButtonTitle: "OK")
alert.show()
}
func paymentQueue(queue: SKPaymentQueue!, updatedTransactions transactions: [AnyObject]!) {
print("add paymnet")
for transaction:AnyObject in transactions {
var trans = transaction as! SKPaymentTransaction
print(trans.error)
switch trans.transactionState {
case .Purchased, .Restored:
print("buy, ok unlock iap here")
//(prprint.productIdentifier)
let prodID = p.productIdentifier as String
switch prodID {
case "IAP id here":
var alert = UIAlertView(title: "Thank You", message: "You may have to restart the app before the banner ads are removed.", delegate: nil, cancelButtonTitle: "OK")
alert.show()
default:
print("IAP not setup")
}
queue.finishTransaction(trans)
break;
case .Failed:
print("buy error")
queue.finishTransaction(trans)
break;
default:
print("default")
break;
}
}
}
func finishTransaction(trans:SKPaymentTransaction)
{
print("finish trans")
}