This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"name": "doge", | |
"imageName": "doge" | |
}, | |
{ | |
"name": "erha", | |
"imageName": "erha" | |
}, | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ViewController: UIViewController { | |
@IBOutlet weak var stackView: UIStackView! | |
@IBOutlet weak var stackViewIndicatorLeadingConstraint: NSLayoutConstraint! | |
fileprivate var previousStackViewIndicatorLeadingConstraintConstant: CGFloat = 0 | |
fileprivate var selectedButton: UIButton? | |
var pageViewController: UIPageViewController? | |
override func viewDidLoad() { | |
super.viewDidLoad() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let renderer = UIGraphicsImageRenderer(size: view.bounds.size) | |
let image = renderer.image { _ in | |
view.drawHierarchy(in: view.bounds, afterScreenUpdates: true) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSString *)base64EncodeString { | |
NSData *data = [self dataUsingEncoding:NSUTF8StringEncoding]; | |
return [data base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength]; | |
} | |
- (NSString *)base64DecodeString { | |
NSData *data = [[NSData alloc] initWithBase64EncodedString:self options:NSDataBase64DecodingIgnoreUnknownCharacters]; | |
return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class LeftAlignedFlowLayout: UICollectionViewFlowLayout { | |
override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? { | |
let attributes = super.layoutAttributesForElements(in: rect) | |
if let attributes = attributes { | |
var previousItemFrame = CGRect.zero | |
for attribute in attributes { | |
if attribute.representedElementKind == UICollectionView.elementKindSectionFooter || attribute.representedElementKind == UICollectionView.elementKindSectionHeader { | |
continue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>老子</h1> | |
<h2 class="subtitle">春秋时代思想家</h2> | |
<div class="image"> | |
<img src="https://upload.wikimedia.org/wikipedia/commons/1/1a/ThaySangLawCin.jpg" alt="老子骑青牛过函谷关"> | |
<p>老子骑青牛过函谷关</p> | |
</div> | |
<h3>简介</h3> | |
<p id="brief">李聃,名耳,字伯阳、外字聃,世人尊称为“老子”,华夏族,生于中夏东周末的某诸侯国苦县厉乡曲仁里(今河南省鹿邑县),师从殷商末臣之商容,于东周春秋末之周守藏室任吏、春秋时代思想家,隐居邢台广阳山。此人有著作被人们广泛奉为<a href="https://www.daodejing.org">《道德经》</a>,是道家的经典、全球文字出版发行量最大的著作之一。 | |
李聃的学说后被庄周、杨朱等人发展[2],后人奉为道家学派之开教宗师。《史记·老子韩非列传》中曾记载孔子向老子请教关于礼的问题。老子主张无为而治、天人合一、清静无为的统治理念,和庄子同样是道家的人物,或与太史儋并列,存世约有一百六十余岁或二百余岁。 | |
李聃被尊为道教始祖、东方三大圣人之首,唐朝追认李聃为李姓始祖。老子是世界文化名人,世界百位历史名人之一。</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name TapTap-Media | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description shows how to use babel compiler | |
// @author Victorchee | |
// @require https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.18.2/babel.js | |
// @require https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.16.0/polyfill.js | |
// @require https://cdn.rawgit.com/eligrey/FileSaver.js/5ed507ef8aa53d8ecfea96d96bc7214cd2476fd2/FileSaver.min.js | |
// @match https://www.taptap.com/app/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class HorizontalCenterScrollFlowLayout: UICollectionViewFlowLayout { | |
override func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint, withScrollingVelocity velocity: CGPoint) -> CGPoint { | |
var offsetAdjustment = CGFloat.greatestFiniteMagnitude | |
let horizontalCenter = proposedContentOffset.x + collectionView!.bounds.width / 2.0 | |
let targetRect = CGRect(x: proposedContentOffset.x, y: 0, width: collectionView!.bounds.width, height: collectionView!.bounds.height) | |
if let attributes = super.layoutAttributesForElements(in: targetRect) { | |
for attribute in attributes { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@IBAction func buttonTapped(_ sender: UIButton) { | |
let pathFrame = CGRect(x: -sender.bounds.midX, y: -sender.bounds.midY, width: sender.bounds.width, height: sender.bounds.height) | |
let path = UIBezierPath(roundedRect: pathFrame, cornerRadius: sender.layer.cornerRadius) | |
let shapePosition = self.view.convert(sender.center, from: self.view) | |
let circleShape = CAShapeLayer() | |
circleShape.path = path.cgPath | |
circleShape.position = shapePosition | |
circleShape.fillColor = UIColor.clear.cgColor | |
circleShape.opacity = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[self.collectionView performBatchUpdates:^{ | |
[self.collectionView reloadSections:[NSIndexSet indexSetWithIndex:0]]; | |
} completion:^(BOOL finished) { | |
}]; |